Binary Heaps and Binomial Heaps Flashcards
What happens to the key values along any path from the root to a leaf?
They are increasing, or a duplicate is encountered.
Reversed
An array of objects that are comparable.
The size of the array(how many objects are in it).
What are the two data variables in the BinaryHeap class?
How do Binomial Queues differ from Binary heaps?
It is not a heap-ordered tree but rather a collection of heap-ordered trees known as a forest.
What kind of binary tree is a heap?
It is a complete Binary Tree
Reversed
at 2i
In a binary heap, where is the left child of the parent at i located?
How does Heap Sort work?
Heap sort begins with a Max Heap data structure. An array is sent to the constructor which builds the heap. DeleteMax is repeatedly called and stores the result in the array until the heap is empty.
Reversed
They are increasing, or a duplicate is encountered.
What happens to the key values along any path from the root to a leaf?
What are the runtimes of Binomial Queues?
insert, deleteMin, and merging are O(Log N) worst case, but on average, inserts take constant time.
How is a binomial tree Bk formed?
By attaching two binomial trees, Bk-1 and Bk-1 together.
Reversed
A b0 tree, a b3 tree, and a b6 tree.
How many Bi top level trees exist in a Binomial heap containing 73 values?
A complete binary tree of height h has how many nodes?
Between 2h and 2h+1-1
What is different about the MaxHeap?
It includes a deleteMax(), instead of a deleteMin()
Reversed
a data structure that allows at least the operations of insert and deleteMin.
What is a priority queue?
What are the 9 methods Included in the BinaryHeap Class?
- 3 constructors
- FindMin
- DeleteMin
- Insert
- PercolateDown
- isEmpty
- MakeEmpty
- EnlargeArray
- BuildHeap
What does the decreaseKey operation do?
It takes a keyLocation and amount to decrease the key by, then the node is percolated up to its new correct location.
Show the result of performing three deleteMin operations on the following Binomial heap.
What is the percolate down algorithm?
- percolateDown(int Hole)
- int child;
- Object tmp = array[hole];
- for( ; hole*2< = currentSize; hole = child)
- child = hole*2;
- if(child ≠ currentSize && array[child] < array[child+1]) child++;
- if(array[child].compareTo(tmp) < 0) array[hole] = array[child];
- else: break;
- array[hole] = tmp;
What is the runtime of FindMin()?
It takes constant time.
Each node in a binomial tree has references to what?
To its first child, and next sibling.
How many Bi top level trees exist in a Binomial hep containing 173 values?
A b0 tree, a b2 tree, a b3 tree, a b5 tree, a b7 tree.
What is the delteMin algorithm?
- Object deleteMin()
- if(isEmpty()) throw error;
- Object Min = array[1];
- array[1] = array[currentSize–];
- percolateDown(1);
- return MinItem;
A Bk Binomial tree consists of what?
A Bk tree contains each of the trees B0, B1, …Bk-1 trees, plus an extra B0 that forms the root of the tree.
Reversed
It begins at the penultimate level.
Where does the buildHeap function begin?
Reversed
A b0 tree, a b2 tree, a b3 tree, a b5 tree, a b7 tree.
How many Bi top level trees exist in a Binomial hep containing 173 values?
Show the result of inserting the sequence of values 10, 21, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, 2 into an initially empty binomial queue