q1keysp01 - COP3530.01, Spring 2001 S. Lang March 6, 2001...

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

View Full Document Right Arrow Icon
COP3530.01, Spring 2001 March 6, 2001 S. Lang Solution Key to Quiz #1 Suppose a binary min-heap consisting of integer values is implemented using array T [0. . n ] in which location T [0] is left unused and locations T [1] through T [ n ] store the n integer values in the heap, n 1. Now answer each of the following questions: 1. (10 pts.) (a) How many leaf nodes does the heap have? Write your answer (as a formula) in terms of n , and give a brief explanation . (A node is a leaf node if it has zero child nodes.) The last node’s index is n , so its parent’s index is n /2 and this is the non-leaf node with the highest index. Thus, there are n /2 non-leaf nodes, so the number of leaf nodes is n n /2 = n / 2 . (b) Give the time complexity in terms of n for each of the following operations (no explanation needed): findMin() – O(1). deleteMin( ) – O(lg n ). findHeight( ) – O(lg
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 06/13/2011.

Ask a homework question - tutors are online