Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5 Building A Heap Using Insertions (15 pts) BUILD-MAX-HEAP as defined on page 157 of CLRS works by repeatedly calling MAX-HEAPIFY from the middle element
5 Building A Heap Using Insertions (15 pts) BUILD-MAX-HEAP as defined on page 157 of CLRS works by repeatedly calling MAX-HEAPIFY from the middle element down to the first element of the array. Consider an alternative definition: BUILD-MAX-HEAP'(A) A.heap-size = 1 for i = 2 to A.length AX--INSERT(A, Ali) 3 (a) Do BUILD-MAX-HEAP and BUILD-MAX-HEAP' always build the same heap when run on the same input array? Prove that they do or provide a counter-example to show that they do not. (b) The text and lecture notes showed that BUILD-MAX-HEAP requires O(n) time to build an n element heap. Show that there is a worst case where BUILD-MAX-HEAP' requires O(n log n) time
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