Abstract Data Structures Binary Trees Root The top

Abstract Data Structures Binary Trees

Root The top node in a tree.

Parent A node within a tree that has nodes that branch off from it (children) Examples: Orlando is a parent to Hartford and Stamford Danbury is parent to Greenville

Child A node within a tree that branches off from another (parent) Examples: Quincy is a child of Stamford Greenville is a child of Danbury

Subtree The grouping of a parent and a child in a tree. Example:

Leaf Examples: Nashua Greenville Quincy Warwick A node with no children within a tree.

Traversal Going through each of the nodes of a tree

Breadth-first traversal Traversing trees in level-order, where every node on a level is visited before going to a lower level. Example: Orlando Hartford Stamford Danbury Nashua Quincy Tampa Greenville Warwick

Depth-first traversal Includes the three traversal methods in-order, preorder, and postorder

Inorder A type of depth-first traversal where a left subtree is processed, then the parent, and then the left subtree. Algorithm: Perform inorder traversal of left subtree Visit node Perform inorder traversal of right subtree

Inorder A type of depth-first traversal where a left subtree is processed, then the parent, and then the left subtree. Example: Danbury Greenville Hartford Nashua Orlando Quincy Stamford Tampa Warwick

Preorder A type of depth-first traversal where a node is visited before its children Algorithm: Visit node Perform inorder traversal of left subtree Perform inorder traversal of right subtree

Preorder A type of depth-first traversal where a node is visited before its children Example: Orlando Hartford Danbury Greenville Nashua Stamford Quincy Tampa Warwick

Postorder A type of depth-first traversal where a node is visited after its children Algorithm: Perform inorder traversal of left subtree Perform inorder traversal of right subtree Visit node

Postorder A type of depth-first traversal where a node is visited after its children Example: Greenville Danbury Nashua Hartford Quincy Warwick Tampa Stamford Orlando

Dynamic Data-Structure A data structure in which the number of elements can change during program execution
- Slides: 16