Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (15pts) Consider the following variation on the BUILD-MAX-HEAP procedure (covered in class): BUILD-MAX-HEAP' (A) 1 A.heap-size = 1 2 for i = 2 to
1. (15pts) Consider the following variation on the BUILD-MAX-HEAP procedure (covered in class): BUILD-MAX-HEAP' (A) 1 A.heap-size = 1 2 for i = 2 to A.length 3 MAX-HEAP-INSERT (A, A[i]) You can find the related subroutines in the textbook (Chapter 6, page 157 and 164) or in the other file in this assignment release folder. Answer the following questions - 1) Do the procedure BUILD-MAX-HEAP' and BUILD-MAX-HEAP always build the same heap when run on the same input array? Justify if your answer is yes, or provide a counter example if your answer is no. 2) Show the worst-case runtime of this variation is (nlgn) when build an n-element heap
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started