Question

For Problems #4 through #6, consider the following pseudocode (ref: CLRSpp. 154-160): 01 HEAP SORT (A) 02 BUILD-MAX-HEAP (A) 03 for i A. length downto 2 04 exchange A [1] and Ali 05 A heapsize A heapsize 1 06 MAX-HEAPIEY (A, 1) 07 BUILD-MAX-HEAP (A) 08 A heapsize A. length 09 for i floor (A length/2) down to 1 10 MAX-HEAPIEY (A ,i) 11 MAX-HEAPIFY (A,i) 12 L 2*i 13 R 2 *i 1 14 if L A. heapsize and ALL] Ali 15 largest L 16 else 17 largest i 18 if R A. heapsize and A. [R] A [largest] 19 largest R 20 if largest i 21 exchange Ali and Allargest 22 MAX-HEAPIFY (A, largest)

Algorithm

Please answer Number 6 right and clearly!

Thanks a lot

0 0
Add a comment Improve this question Transcribed image text
Answer #1

i 6 puen unǐhak Content 16 22 284 o28 3 2 /6 64 anderts BUILD-MAY-HCAP :- Contents Dtarnaj A just, pwr dotte execut on t Jane

Add a comment
Know the answer?
Add Answer to:
Algorithm Please answer Number 6 right and clearly! Thanks a lot For Problems #4 through #6,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please ignore red marks. Thanks 6. (8 pts) Illustrate the algorithmic operations on the maximum binary...

    Please ignore red marks. Thanks 6. (8 pts) Illustrate the algorithmic operations on the maximum binary heap data sti 'perations on the maximum binary heap data structure as directed. BUILD-MAX-HEAP(A) MAX-HEAPIFY (A. i) 1 A heap-size = A.length 11 = LEFT() 2 for i = A.length/2) downto 1 2 r = RIGHT() 3 MAX-HEAPIFY (A,i) 3 if / S 4.heap-size and All > A[i] HEAP-EXTRACT-MAX (A) 4 largest = 1 5 else largest = 1 1 if A.heap-size <1 6...

  • 2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running...

    2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running time analysis for both best and worst case. 3. Consider the age data of 12 children who are supposed to undergo for vaccination in ascending order of their age. Suggest and apply a sorting technique which can efficiently handle this data. Show all the intermediate steps clearly. Child ID 01 02 03 04 05 06 07 08 09 10 11 12 2. Age 1...

  • 01 Set value of Number to 10 02 Set value of Counter to 6 03 Set...

    01 Set value of Number to 10 02 Set value of Counter to 6 03 Set value of Total to 0 04 Add Counter to Total 05 If Counter is less than 1, jump to step 09 06 add Number to Total 07 Subtract 1 from Counter 08 Jump to step 05 09 End Given the pseudocode algorithm above, what is the value of Total when step 09 is reached?

  • Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART...

    Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART A PART B Assignment 1 #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <stdio.h> #include <ctype.h> #include <string.h> #include <algorithm> using namespace std; /** This structure is to store the date and it has three integer fields **/ struct Date{    int day;    int month;    int year; }; /** This structure is to store the size of the box and it...

  • Need to code the HeapSort Algorithm in java. Most of the code is already done just...

    Need to code the HeapSort Algorithm in java. Most of the code is already done just need to code the "heapify" part of the heapsort algorithm. My heapify code is in bold below called "sink", but when I run it it gives me 2 errors with the string compare part saying: WordCountHeap.java:61: error: cannot find symbol         if(l < k && String.Compare(pq[l], pq[n]) < 0)                           ^ symbol:   method Compare(String,String) location: class String Please fix the code and the "heapify"...

  • P12-5 a,b,c,d please solve P12-5 a,b,c,d by referring P12-4 P12-5 a,b,c,d What is the economic value...

    P12-5 a,b,c,d please solve P12-5 a,b,c,d by referring P12-4 P12-5 a,b,c,d What is the economic value of the bonds on December 31,2001? CHAPTER 12 LONG-TERM LIABILITIES g. What should the liability value and the economic value of the bonds be on January 1, 2011, the maturity date of the bonds? Explain. 213 oh. Prepare the entry to record the retirement of the bonds on January 1,2011. P12-5 Refer to P12-4. Assume that on June 30, 2009, market interest rates soared...

  • 2.-Interpret the following regression model Call: lm(formula = Sale.Price ~ Lot.Size + Square.Feet + Num.Baths + API.2011 + dis_coast + I(dis_fwy * dis_down * dis_coast) + Pool, data = Train...

    2.-Interpret the following regression model Call: lm(formula = Sale.Price ~ Lot.Size + Square.Feet + Num.Baths + API.2011 + dis_coast + I(dis_fwy * dis_down * dis_coast) + Pool, data = Training) Residuals: Min 1Q Median 3Q Max -920838 -84637 -19943 68311 745239 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -7.375e+05 7.138e+04 -10.332 < 2e-16 *** Lot.Size -5.217e-01 1.139e-01 -4.581 5.34e-06 *** Square.Feet 1.124e+02 1.086e+01 10.349 < 2e-16 *** Num.Baths 3.063e+04 9.635e+03 3.179 0.00153 ** API.2011 1.246e+03 8.650e+01 14.405 < 2e-16...

  • please do not copy from previous posted answer (20pts) 6. Assume that a data segment in...

    please do not copy from previous posted answer (20pts) 6. Assume that a data segment in 80x86 Assembly has the following declarations: dw 1ABBH W х db 16 у db 'wxy' Z dw -26, 11 address 00. Show the values as they would appear in debug. Assume the memory starts Address 00 01 02 03 04 05 06 07 08 09 Value Given the above data segment, play computer with the following code and show the final hexadecimal values of...

  • P12-6 (a)through (D) f. What is the 3. What she bat is the economic value of...

    P12-6 (a)through (D) f. What is the 3. What she bat is the economic value of the band the should the ability valstand the 2011, the maturity date of the bond record the retirement of the bod 1. 2011. the mat h. Prepare the Prepare the entry to record the P12-4. Assume that on June 30, 2009.market interest ae meae P12-5 Refer to P12-4. A Required: a. Compute the eco b. Comment on any y 1. anuary 11 e d...

  • The file containing the JAVA files, pseudocode file and doc file that have written for this...

    The file containing the JAVA files, pseudocode file and doc file that have written for this lab. Preamble The file releasedates.txt contains a list of video games and their release dates. Each line of the file contains the release date, a tab character, and then the name. The list is currently totally unsorted. The object of today's lab is to write a series of methods that allow us to perform the following tasks: read contents from a file and store...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT