Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
26.1.5. Heaps
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
3 cards from this lesson. Good the night before a test.
Try these first
- 1.
What is a heap?
Hint
Remember the structure and purpose.
- 2.
What does a Min-Heap guarantee about its parent and children?
Hint
Think about the smallest value in the tree.
- 3.
What is the time complexity of inserting an element into a heap?
- O(n)
- O(log n)
- O(1)
Hint
Think about how trees are structured.
- 4.
True or False: A Max-Heap allows the parent node to be less than its children.
- True
- False
Hint
Consider how the elements compare in a Max-Heap.
- 5.
You have the array [4, 10, 3, 5, 1]. Build a Min-Heap from this array and show the resulting array representation.
Hint
Try to construct the heap level by level while maintaining the properties.
- 6.
Explain how the complexity of a sorted array compares to the performance of a heap for insertions and deletions.
Hint
Think about how elements are organized in both structures.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting