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.Input Format
Input is managed for you
Output Format
Output is managed for you
Constraints
None
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
add 10 add 20 add 30 add 40 peek add 50 peek remove peek remove peek remove peek remove peek quit
Output
10 10 10 20 20 30 30 40 40 50