Write Priority Queue Using Heap
easy
1. You are required to complete the code of our Priority Queue class using the heap data structure. Please watch the question video carefully. The theoretical details of required functionality is explained in detail there. Implement the functions to achieve what is explained in the theoretical discussion in question video. 2. Here is the list of functions that you are supposed to complete: 2.1. add -> Should accept new data. 2.2. remove -> Should remove and return smallest value, if available or print "Underflow" otherwise and return -1. 2.3. peek -> Should return smallest value, if available or print "Underflow" otherwise and return -1. 2.4. size -> Should return the number of elements available. 3. Input and Output is managed for you.
Constraints
None
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
add 10
add 20
add 30
add 40
peek
add 50
peek
remove
peek
remove
peek
remove
peek
remove
peek
quit
Sample Output
10
10
10
20
20
30
30
40
40
50
Question Video