# Lecture Notes for CS 245 - Data Struct & Algorithms with Galles at University of San Francisco (USF)

## Notes Information

 Material Type: Class Note Professor: Galles Class: CS 245 - Data Struct & Algorithms Subject: Computer Science University: University of San Francisco (CA) Term: Summer II 2009 Keywords: On the RightOn the LeftIndentationInorder TraversalBinary Search

## Sample Document Text

Data Structures and Algorithms CS245-2009S-07 Tree Operations David Galles Department of Computer Science University of San Francisco 07-0: Binary Tree Definition class Node { Node() { } Node(Comparable elem) { element_ = element; } Node(Object element, Node left, Node right) { element_ = element; left_ = left; right_ = right; } /* Access methods on next slide */ private Node left_; private Node right_; private Comparable element_; } 07-1: Binary Tree Access Methods Node left() { void setLeft(Node left) { return left_; left_ = left; } } Node right() { void setRight(Node right) { return right_; right_ = right; } } Comparable element() { return element_; } void setElement(Comparable element) { element_ = element; } 07-2: Tree Operations - Height Returns the height of the tree (Length of the path to the deepest leaf) + 1 Height = 5 Height = 6 07-3: Tree Operations - Height int height(Node tree) { if (tree == null) return 0; return 1 + MAX(height(tree.left()), height(tr...

## Related Documents

On the Right Notes
Inorder Traversal Notes
Display Property Notes
On the Left Notes
Binary Search Notes
On the Right Notes
Binary Search Notes
On the Left Notes
On the Right Notes
Positioning Notes
On the Left Notes
On the Left Notes
On the Left Notes
On the Right Notes
On the Right Notes
On the Left Notes