0
0
DSA Typescriptprogramming~5 mins

Heap Extract Min or Max Bubble Down in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the 'bubble down' operation in a heap after extracting the min or max element?
The 'bubble down' operation restores the heap property by moving the root element down the tree, swapping it with its smaller (min-heap) or larger (max-heap) child until the heap order is correct.
Click to reveal answer
beginner
In a min-heap, after extracting the minimum element, which element replaces the root before bubbling down?
The last element in the heap replaces the root before the bubble down process begins to restore the heap property.
Click to reveal answer
intermediate
What condition determines when to stop the bubble down process in a heap?
Bubble down stops when the current node is smaller (min-heap) or larger (max-heap) than both its children or when it has no children.
Click to reveal answer
intermediate
Why do we swap the current node with the smaller (min-heap) or larger (max-heap) child during bubble down?
Swapping ensures the heap property is maintained by moving the out-of-place element down to a position where it is correctly ordered relative to its children.
Click to reveal answer
beginner
Show the TypeScript signature of a bubble down function for a min-heap.
function bubbleDown(heap: number[], index: number): void
Click to reveal answer
What element is removed during the extract operation in a min-heap?
AThe largest element
BThe last element
CThe root element (minimum)
DA random element
After removing the root in a max-heap, which element temporarily replaces the root before bubbling down?
AA new element
BThe smallest element
CThe second largest element
DThe last element in the heap
During bubble down in a min-heap, you swap the current node with:
AThe smaller child
BThe larger child
CThe parent node
DNo one, you only move up
When does the bubble down process stop?
AAfter one swap
BWhen the node is smaller (min-heap) or larger (max-heap) than its children or has no children
CWhen the heap is empty
DWhen the node reaches the root
What is the time complexity of the bubble down operation in a heap?
AO(log n)
BO(n)
CO(1)
DO(n log n)
Explain step-by-step how the bubble down operation works after extracting the root in a min-heap.
Think about how the heap property is maintained by moving the root down.
You got /4 concepts.
    Describe why bubble down is necessary after extracting the min or max element from a heap.
    Consider what happens to the heap shape and order after extraction.
    You got /4 concepts.