Question
Write a pseudocode function which takes two parameters: heap1 and heap2, and returns an integer. The function should return the 3rd largest number contained in
Write a pseudocode function which takes two parameters: heap1 and heap2, and returns an integer. The function should return the 3rd largest number contained in both heaps. Both heap1 and heap2 are maxheaps containing integers, and both heaps have at least 3 elements.
For example, if heap1 contains 10, 7, 6, 4, 1 and heap2 contains 8, 4, 3 your function should return 7. If heap1 contains 10, 7, 4 and heap2 contains 5, 4, 3 your function should return 5. It is acceptable if heap1 and heap2 are changed during the function call.
Assume you have a class Heap implemented which implements the following heap functions discussed in the videos and textbook (and only the following functions).
+isEmpty(): boolean
+getNumberOfNodes(): integer
+add(newEntry: ItemType): boolean
+peek(): ItemType
+remove(): boolean
bronze(heap1: Heap, heap2: Heap): integer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started