Recall & Review
beginner
What is a min-heap?
A min-heap is a special tree-based data structure where the value of each parent node is less than or equal to the values of its children. This means the smallest value is always at the root.
Click to reveal answer
beginner
What is a max-heap?
A max-heap is a tree-based data structure where the value of each parent node is greater than or equal to the values of its children. This means the largest value is always at the root.
Click to reveal answer
beginner
What property must every node satisfy in a min-heap?
Every node's value must be less than or equal to the values of its children nodes.
Click to reveal answer
intermediate
How does a max-heap maintain its structure after inserting a new element?
After insertion, the new element is placed at the bottom and then 'bubbled up' by swapping with its parent until the max-heap property is restored (parent is larger or equal).
Click to reveal answer
intermediate
Why are heaps useful for priority queues?
Heaps allow quick access to the highest or lowest priority element (root), and insertion or removal operations happen efficiently, making them ideal for priority queues.
Click to reveal answer
In a min-heap, where is the smallest element located?
✗ Incorrect
The min-heap property ensures the smallest element is always at the root.
Which of the following is true about a max-heap?
✗ Incorrect
In a max-heap, each parent node is greater than or equal to its children.
What happens when you insert a new element into a min-heap?
✗ Incorrect
New elements are added at the bottom and moved up to maintain the min-heap property.
Which data structure is best for quickly finding the largest element?
✗ Incorrect
A max-heap keeps the largest element at the root for quick access.
Why do heaps make good priority queues?
✗ Incorrect
Heaps allow quick access to the highest or lowest priority element, which is essential for priority queues.
Explain the main difference between a min-heap and a max-heap.
Think about which element is at the top in each heap.
You got /3 concepts.
Describe how a heap maintains its property after inserting a new element.
Consider the 'bubble up' or 'heapify' process.
You got /4 concepts.