11653 - HW3 - Max Heap   

Description

The goal of this homework is to implement a max heap.
You are asked to implement 6 functions below:
1Insert (int value) : Insert a data element into the heap.
2. DeleteMax() : Delete the root node.
3. MaxPathWeight (int index) : Return the max path weight from root to leaf.
4. InorderTraversal (int index) : Return the inorder traversal path from root.
5. PreorderTraversal (int index) : Return the preorder traversal path from root.
6. PostorderTraversal (int index) : Return the postorder traversal path from root.
 
•Note:
1. Each data is an integer ranges from 1 to 99999.
2. Each node is unique, two duplicate integers won’t exist at the same time.
3. There will exists at most 99999 nodes in the heap.
4. Root index is 1.

Input

Input will contain function name and integer

eg:
Insert 1
DeleteMax
MaxPathWeight
InorderTraversal 
PreorderTraversal
PostorderTraversal 
End

Output

Four functions will output the corresponding values.

MaxPathWeight
InorderTraversal 
PreorderTraversal
PostorderTraversal 

Each traversal path is output in the format: Int Int Int Int …… Int

In the end, we will output the whole heap, but you don’t need to handle it.

Insert
DeleteMax

Above two functions won’t output anything.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11653.cpp

Partial Judge Header

11653.h

Tags

777 778



Discuss