

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Padua-Perez; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Study notes
1 / 33
This page cannot be seen from the preview
Don't miss anything!


























Parent node Children nodes
⇒^ node with same parent Descendent
⇒^ children nodes & their descendents Subtree
⇒^ portion of tree that is a tree by itself^ ⇒^ a node and its descendents
Subtree
Siblings
⇒^ is a measure of a node’s distance from root Definition of level^ If node is the root of the tree, its level is 1^ Else, the node’s level is 1 + its parent’s level Height (depth)
⇒^ max level of any node in tree
Height = 3
Preorder
parent before children
Inorder
left child, parent, right child
Postorder
⇒^ children before parent Breadth first
⇒^ closer nodes first
// insert node into Q
while ( !Q.empty()) {^ n = Q.dequeue();
// remove next node
if ( !n.isEmpty()) {^ visit(n);
// visit node
Q.enqueue(n.Left());
// insert left subtree in Q
Q.enqueue(n.Right());// insert right subtree in Q } }
Degeneratebinary tree
Balancedbinary tree
Smaller values in left subtree Larger values in right subtree Example X > Y X < Z
10 > 2, left 5 > 2, left 2 = 2, found 45
5 > 2, left 2 = 2, found
10 < 25, right 30 > 25, left 25 = 25, found 45
5 < 25, right 45 > 25, left 30 > 25, left 10 < 25, right 25 = 25, found