Answered step by step
Verified Expert Solution
Question
1 Approved Answer
BUILD-MAX-HEAP(A) 1 A.heap-sizeA.length 2 fori LA. length/2] downto 1 3 MAX-HEAPIFY (A, i) BUILD-MAX-HEAP (A) 1 A.heap-size1 2 for i 2 to A.length 3 MAX-HEAP-INSERT(A,
BUILD-MAX-HEAP(A) 1 A.heap-sizeA.length 2 fori LA. length/2] downto 1 3 MAX-HEAPIFY (A, i) BUILD-MAX-HEAP (A) 1 A.heap-size1 2 for i 2 to A.length 3 MAX-HEAP-INSERT(A, Ai) (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 (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