Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions