Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Only do Part b) 2. [10 You are given a binary max-heap H and you will design the following two algorithms with different requirements. For

image text in transcribed

Only do Part b)

2. [10 You are given a binary max-heap H and you will design the following two algorithms with different requirements. For both algorithms you may assume that the size of H is at least 3, and that all elements in H have distinct values. (a) Design the EXTRACT-THIRD-LARGEST (H) algorithm which removes and returns the third largest element in H The worst-case runtime must be O(logn). Write the pseudocode of your algorithm and justify its correctness and worst-case runtime. (b) Design the GET-THIRD-LARGESTCH) algorithm which returns the third largest element in H without removing it. The worst-case time complexity of your algorithm must be as low as possible. Only the fastest possible algorithm will get full mark. Write the pseudocode of your algorithm and justify its correctness and worst-case runtime Note: For both designs you may use the following functions that we learned from the lecture as helper functions: BUBBLE-DOWN, EXTRACT-MAX, INCREASE-KEY and INSERT

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

Step: 3

blur-text-image

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions