Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are five parts to this problem (HW4.3A,HW4.3B,HW4.3C,HW4.3D,HW4.3E). Assume you have an eight-element array containing the letters HEAPSORT ...which need to be sorted via Heapsort

There are five parts to this problem (HW4.3A,HW4.3B,HW4.3C,HW4.3D,HW4.3E). Assume you have an eight-element array containing the letters HEAPSORT ...which need to be sorted via Heapsort into ascending order (that is, alphabetical order: letters at the front of the alphabet are 'small', and letters at the end are 'big'). HW4.3A: Show what the (unordered) heap structure will look, based on the current arrangement of letters. (That is, show a picture like Figure 4.17d on Page 183, but before imposing a partial order.) HW4.3B: Begin running the constructHeap routine on this heap structure, showing the new arrangement of the letters in the tree after the left and right subtrees have been turned into heaps. NOTE: There are of course several intermediate steps, but you are NOT required to show those! HW4.3C: Show the final arrangement of the letters after constructHeap finishes. Note that if 'T' is not at the top of the heap at this point, you must have done something wrong, since you should now have a valid heap, not just a heap structure. HW4.3D: Now run deleteMax (only once!), and show what the resulting 7-node heap will look like after deleteMax finishes (that is, right after the call to fixHeap). Heapsort of course will call deleteMax over and over again to finish the sorting, but you are NOT required to do this; I only want you to run deleteMax once in HW4.3D. HW4.3E: Now continue with Heapsort until you run deleteMax for the second time, and show what the 8-element array will look like AT THIS POINT in the algorithm (6 elements in the heap, and 2 'sorted' elements). NOTE: you may wish to consider this a 9-element array, since E(0) is always unused. (I'm only asking for a list of array values in 4.3E, but you will almost certainly have to draw and manipulate the heap structure in order to envision how the elements interact. Indeed, you should show your 'new' heap so that you can at least get partial credit if you do something wrong.) Note that I'm NOT asking for what the array will look like at the end of Heapsort (that would be boring!), but at the point where two elements are sorted and the remaining 6 are still in the heap. Remember, in HW4.3E, SHOW THE ARRAY, not just the heap.

I will open 2 more for this if one got answered. just copy and paste it, I will give you likes. Thank you

use java, c ++ or python, to give sudo code

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions