{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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;
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

{[ snackBarMessage ]}

Ask a homework question - tutors are online