0% found this document useful (0 votes)
36 views1 page

Fundamental Algorithms, Problem Set 1 Due Thursday, Feb 5, in Recitation

The document provides instructions for Problem Set 1 in Fundamental Algorithms that is due on February 5th. It includes 6 problems related to max-heap and min-heap operations like HEAP-INCREASE-KEY, MAX-HEAPIFY, BUILD-MAX-HEAP, and HEAP-DELETE. The problems ask how many exchanges may occur in each operation and ask the student to illustrate the BUILD-MAX-HEAP operation on a sample array.

Uploaded by

Tarang Dawer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Fundamental Algorithms, Problem Set 1 Due Thursday, Feb 5, in Recitation

The document provides instructions for Problem Set 1 in Fundamental Algorithms that is due on February 5th. It includes 6 problems related to max-heap and min-heap operations like HEAP-INCREASE-KEY, MAX-HEAPIFY, BUILD-MAX-HEAP, and HEAP-DELETE. The problems ask how many exchanges may occur in each operation and ask the student to illustrate the BUILD-MAX-HEAP operation on a sample array.

Uploaded by

Tarang Dawer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Fundamental Algorithms, Problem Set 1

Due Thursday, Feb 5, in Recitation


The world can be divided into those who love New York City and
those who dont. Those who love New York tend to be unusually
lively people. They have to be. Characteristically, they are
ambitious, curious, intellectually vigorous, culturally alive. Such
people give New York City institutions great dynamism and some
eccentricity.
James Hester 1924-2015, NYU President
1. Let A is a max-heap with heapsize fifty million, being used as a priority
queue. Suppose HEAP-INCREASE-KEY(A,300,key) is called. What is
the maximum number of exchanges that can take place. What is the
minimal number of exchanges that can take place.
2. When A is a array with length fifty million and MAX-HEAPIFY(A,300)
is called. What is the maximum number of exchanges that can take
place. What is the minimiml number of exchanges that can take place.
3. Consider a min-heap H with length 1023. 1 Assume the elements of
the array are distinct. Let x be the third smallest element in the array.
What are the possible positions for x. Let y = H[700]. Can y be the
largest element in the array? Can y be the smallest element in the
array? Bonus Question: Give all i for which it is possible that y is
the i-th smallest element of the array.
4. Using the figures in the text as a model, illustrate the operation of
BUILD-MAX-HEAP on the array A = (5, 3, 17, 10, 84, 19, 6, 22, 9)
5. The operation HEAP-DELETE(A,t) deletes the item in node t from heap
A. Give an implementation of HEAP-DELETE that runs in O(lg n) time
for an n-element max-heap.
6. Let A be an array of length 127 in which the values are distinct and
in increasing order. In the procedure BUILD-MAX-HEAP(A) precisely
how many times will two elements of the array be exchanged? Now
suppose the values are distinct and in decreasing order. Again, in
the procedure BUILD-MAX-HEAP(A) precisely how many times will two
elements of the array be exchanged?
1

Did you recognize 1023 as a special number? Its one less than 1024 = 210 . The binary
tree with that many nodes just fills out a row!

You might also like