Page 1 of 1

Problem HeapPriority Queue class gives an ArrayList based implementation of a heap. It includes a constructor that uses

Posted: Thu Jun 02, 2022 8:13 am
by answerhappygod
Problem Heappriority Queue Class Gives An Arraylist Based Implementation Of A Heap It Includes A Constructor That Uses 1
Problem Heappriority Queue Class Gives An Arraylist Based Implementation Of A Heap It Includes A Constructor That Uses 1 (84.71 KiB) Viewed 20 times
Problem HeapPriority Queue class gives an ArrayList based implementation of a heap. It includes a constructor that uses the method heapify() for bottom-up construction of heap from a given list of (key,value) entries. Implement a method preorder_heapify that constructs the heap such that pre-order traversal of the heap gives a sorted sequence of the keys. An example for such a heap is given below. Test Scenario: Test your implementation by creating a heap for keys from 1 to 25 (values could be set equal to keys): First create your heap using heapify() method, perform preorder traversal and print the result. Then modify your heap using preorder_heapify method, perform preorder traversal, print the result and show that keys are sorted. pre-order traversal: [1,2,3,4,5,6] 6