Midterm 2 Review

14 exercise616263 15

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e left and the right subtree of the root. 13) What is the smallest (largest) number of nodes in a heap of height 6? What is the height of a heap with 200 nodes? Height is defined as the number of nodes in the longest path from the root to a leaf. Thus the height of a heap with 3 nodes is 2. 14) Exercise 6.1, 6.2, 6.3 15) Recall that we presented an algorithm to remove a key at position j (which is also described in the text.) Here is another possible way to remove a key at position j: move the key at A[currentSize] to A[j] and call percolateDown (j). Will this work? If so, prove it. Otherwise, give an example for which it fails. 16) Write a procedure to delete the second smallest key from a min heap. Your procedure should perform only a constant number of additional operations besides calling INSERT or DELETEMIN. (It should return the second smallest key.) What is the complexity of your procedure? 17) Obtain the sum of the following series: a. 1 x 31 + 2 x 32 + 3 X 33 + … + n x 3n b. 21...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 315 taught by Professor Kooshesh,a during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online