Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions