Question

In: Computer Science

Consider a binomial heap where only insert and findmin operations are allowed (no extractmin). Show that...

Consider a binomial heap where only insert and findmin operations are allowed (no extractmin). Show that both of these operations can be done in amortized O(1) time. Hint: For findmin consider explicitely storing a pointer to the tree with minimum root and then update it during insert if needed. For insert, you’ll need to use amortization and develop a good potential function.

Solutions

Expert Solution

Solution: A binomial heap is actually nothing but a collection of min heaps. Since we know that in a min-heap, the minimum element is always present at the root node of the tree, therefore, the minimum element can always be found at the top of the tree in a constant amount of time that is O(1). It can be easily performed by traversing to the minimum root node of the tree which can be implemented using a pointer that is always pointing to the minimum key root of the binomial tree.

On, the other hand, the insertion in the tree has to be done at the leaves and hence the heapify algorithm has to be called within that heap of the binomial heap and hence it would take O(log N) of time where n is nothing but the level of the particular heap within the binomial heap and hence the insertion would take O(1) of time but the heapify would be called and it would take an additional O(log N) time.

Here's the solution to your question, please provide it a 100% rating. Thanks for asking and happy learning!!


Related Solutions

We can build a heap by repeatedly calling the insert function to insert the elements into...
We can build a heap by repeatedly calling the insert function to insert the elements into the heap. Here is pseudocode: buildHeap(A) h = new empty heap   for each element e in A       h.insert(e)             What is the Big-O runtime of this version of buildHeap? Justify your answer.
1.Instead of Build-Max-Heap, we could use Heap-Insert-Max to build a tree with heap property. Write a...
1.Instead of Build-Max-Heap, we could use Heap-Insert-Max to build a tree with heap property. Write a pseudocode for that procedure, also evaluate it’s time complexity. 2. How Insertion sort works on the following array [16, 12, 3, 27, 9, 4, 5, 7]]
Give an algorithm for reversing a queue Q. Only following standard operations are allowed on queue....
Give an algorithm for reversing a queue Q. Only following standard operations are allowed on queue. 1. enqueue(x) : Add an item x to rear of queue. 2. dequeue() : Remove an item from front of queue. 3. empty() : Checks if a queue is empty or not.. (Hint: you can use LinkedList, Stacks, and Queues from the java data collection) OUTPUT Examples: Input : Q = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] Output :Q =...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and simulating a prioritized row of integers with higher priority value. I would appreciate if someone could help me with this code It has to include the following on the code: push Description: Add data to prioritized row Entry: An integer, which you want to add to the prioritized row Exit: Nothing Precondition: n is an integer Postcondition: The prioritized row contains new data. pop...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and simulating a prioritized row of integers with higher priority value. It has to include the following on the code: push Description: Add data to prioritized row Entry: An integer, which you want to add to the prioritized row Exit: Nothing Precondition: n is an integer Postcondition: The prioritized row contains new data. pop - Description: Remove the data with the highest priority from the...
Please only edit the list.cpp file only, implement the push_front method that will insert a new...
Please only edit the list.cpp file only, implement the push_front method that will insert a new element to the front of the list. //list.h // Doubly linked list #ifndef Q2_H #define Q2_H template<typename T> class List; template<typename T> class Iterator; template <typename T> class Node {    public:        Node(T element);    private:        T data;        Node* previous;        Node* next;    friend class List<T>;    friend class Iterator<T>; }; template <typename T> class List...
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap, you need to assign a priority (key) to each item that will determine where it is inserted in the heap 7a) Show how to assign priorities to items to implement a first-in, first-out queue with a heap. 7b) Show how to assign priorities to items to implement a first-in, last-out stack with...
Make a program to perform Heap Sort, must run in Alice programming only. Only correct answers...
Make a program to perform Heap Sort, must run in Alice programming only. Only correct answers needed should be in given language Wrong answers will be downvoted
Pretend that our galaxy is a heap of sand, where each grain of sand is a...
Pretend that our galaxy is a heap of sand, where each grain of sand is a star, that is about 10 inches across. Since the actual Milky Way is 100,000 light years across, you can act like each inch of your pile represents 10,000 light years. Describe your heap of sand mention how thick it is, how many grains of sand there will be, what it will look like, and what properties it would have.
Suppose you have a min-heap in an array a[] where: ● The root isstored at...
Suppose you have a min-heap in an array a[] where: ● The root is stored at index 1 ● There are 15 elements (in a[1]...a[15]) ● There are no duplicates (this is not true in general for heaps; but assume it is true for this problem). Fill in the blanks in the statements below; the resulting statement must be true for any heap obeying the above properties.There are/is at least ____6_______ elements in theheap that are/is larger than a[3] ""There...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT