- Discuss the following with your neighbor:
- What are the advantages of using a heap data structure?
- Name several scenarios where a heap is advantageous.
- Name some scenarios where a heap is not advantageous.
- Are the following heaps valid? If not, do they violate the structure and/or heap-order property?
D. |
|
E. |
|
- Insertions and Deletions
- Draw the resulting heap after inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13 and 2 into an initially empty binary heap and show its array representation.
- Using the heap from the previous question, what does top() return?
- Using the heap from the previous question, draw the heap and its array after a call to pop().
- Using the heap from the previous question, what does top() return?
- Using the heap from the previous question, draw the heap and its array after a call to pop().
- Using the heap from the previous question, what does top() return?
- Using the heap from the previous question, draw the heap and its array after a call to pop().
- What are the following Big-Ohs for Heaps?
Operation |
Average-case |
Worst-case |
insert |
|
|
top |
|
|
pop |
|
|
Last Modified: