sol8 - else if(current.value> current.leftchild.value...

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

View Full Document Right Arrow Icon
Cop3530 Solution 8 1. a) Proof: Since all values in the tree are distinct real value, there is a minimum number among all the values. And the node with this value will be global minimum which is also a local minimum. b) Algorithm: (exceptions and bounderies are not handled) current=root; while(current!=Null) { if((current.value < current.leftchild.value) &&(current.value < current.rightchild.value)) return current;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else if (current.value > current.leftchild.value) current=current.leftchild; else if (current.value > current.rightchild.value) current=current.rightchild; } 2. Print_tree(node t, int depth) { If (t != null){ for(i=1;i<=depth) print(“…”); numOfChildren = t.numOfChildren print(t.value + "(" + numOfChildren + ")" ) for(i=1;i<=t.numOfChildren) Print_tree(t.i thChild,depth+1); } }...
View Full Document

This note was uploaded on 01/15/2010 for the course COP 3530 taught by Professor Davis during the Fall '08 term at University of Florida.

Ask a homework question - tutors are online