Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use the correct time complexity Problem #2: (45 pts) (a) Consider a binary min-heap. Assume that we have a method that print the keys

image text in transcribedimage text in transcribed

Please use the correct time complexity

Problem #2: (45 pts) (a) Consider a binary min-heap. Assume that we have a method that print the keys as encountered in a preorder traversal. Is the output sorted? Justify your answer. Attempt the same question for inorder and postorder traversal (b) Propose a O(n) running time complexity algorithm (only pseudo-code) to find all nodes less than some value X in a binary min-heap. Analyze its complexity. Justify (c) Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time and in the giver order, into an initially empty binary min heap (d) Show the result of performing three deleteMin operations in the heap of the previous binary min heap (e) Write a method replaceKey in the MinHeap class with the following signature public void replaceKey (Integer oldKey, Integer newKey) The method will replace the first occurrence of oldKey with the newKey, and restore the Min-Heap property after the change. If the oldKey does not exist in the heap, the method prints an appropriate message and returns without changing the heap Example: Suppose our binary heap object (bh) has the following keys 32 19 kxo 4 64 26 99 42 54 28 Then the method call: bh.replaceKey (oldKey Integer (54), newKey Integer(2)) should change the keys to: x2 4 32 6 64 26 99 42 19 28 Note: You can assume that the methods perlocateUp and perlocateDown are already implemented in your MinHeap class

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago