Which of the following is the algorithm for insertion in a heap?
A) Insert the new item in the next position at the bottom of the heap.
while new item is not at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
B) Insert the new item in the next position at the top of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
C) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is larger that its parent
Swap the new item with its parent, moving the item up the heap.
D) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item down the heap.
Correct Answer:
Verified
Q15: Using Huffman codes to encode text files
Q16: A set of nodes T is a
Q17: Searching a binary search tree is a(n)
Q18: Which of the following is the preorder
Q19: Which of the following is the postorder
Q20: In a priority queue, the poll method
Q21: Complete the following algorithm which recursively inserts
Q23: Insertion into and removal from a heap
Q24: The following algorithm is a(n) _ .
If
Q25: Expanding and contracting arrays are _ operations.
A)
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents