{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# asg8 - would be unacceptable 2 Write a Java method...

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

COP 3530 Assignment 8 Due: 21 st Oct 2009 1. Consider an n-node complete binary tree T, where n = 2d 1 for some d > 0. Each node v of T is labeled with a real number x v . You may assume that the real numbers labeling the nodes are all distinct. A node v of T is a local minimum if the label x v is less than the label x w for all nodes w that are joined to v by an edge (parent or children). a) Prove that any such tree has at least one local minimum. b) Give your most time-efficient (fewest comparisons) algorithm for finding a local minimum of T. An algorithm that uses O(n) comparisons
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: would be unacceptable. 2. Write a Java method treeprint(node t, int n) that will print a tree in indented form, using a preorder traversal. The argument n is the current depth in the tree, whose value at the beginning of the recursion is assumed to be zero. Example: a (3) ... b (1) ... . .. c(0) ... d (2) ... . .. e (0) ... . .. f (0) ... g (0) In this tree, a has 3 children (b,d,g), b has one child (c), and d has 2 children (e and f)....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online