hw3-soln - CSCI 4041 HW#3 Solution Key (Fall 2009) 1....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI 4041 HW#3 Solution Key (Fall 2009) 1. [30pt] a. [15pt] Successive calls to Tree-Successor constitute a partial traversal of the tree, starting at node x and continuing for next k nodes. The successive calls will involve O(k+h) nodes, which implies a total of O(k+h) distinct edges will be traversed because it is tree. However, each such edge will be traversed at most twice: once going down and once coming up. The complexity of the algorithm is of the order of the number of edge traversals. The partial traversal which is done by k successive calls to Tree-Successor will visit at least k nodes (the k successors of x). Assuming we start at node x. Let y be the k^th successor of x, i.e., the last node obtained in the k successive calls. The traversal may visit some number of additional nodes with keys <= key(x) and keys >= key(y). In the worst case, node x is a leaf at maximum depth h whose successor corresponds to the root. The number of nodes visited with keys <= key(x) is h-2. So, the number of
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/18/2010 for the course CSCI 4041 taught by Professor Karypis during the Spring '08 term at Minnesota.

Page1 / 2

hw3-soln - CSCI 4041 HW#3 Solution Key (Fall 2009) 1....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online