Professional Documents
Culture Documents
Trees Fundamentals: Student - Feedback@sti - Edu
Trees Fundamentals: Student - Feedback@sti - Edu
Trees O and N
I and K
Fundamentals A and Q
• A tree represents a hierarchical nature of a structure in a Leaf nodes I, K, A, Q, T
graphical form. It consists of elements or nodes, with each One-level subtrees B-E/R
node linked to its successors. E-O/N
• The best example of a tree is the computer's file system: R-I/K
C:\Users\bpena\Desktop\TreeDemo.java O-A/Q
• The top of a tree is called its root. The links from a node to its N-T
successors are called branches, edges, lines, or paths. Nodes per level Level 0 – B
• The successors of a node are called its child nodes or Level 1 – E, R
children. The predecessor of a node is called its parent. Level 2 – O, N, I, K
• A tree is considered a binary tree if all its nodes have two (2) Level 3 – A, Q, T
child nodes at most. Depth 3
• Each node in a tree has exactly one (1) parent except for the Degree of each one-level Subtree B – 2
root node, which has no parent. subtree Subtree E – 2
• Nodes that have the same parent are siblings. Subtree R – 2
• A node that has no child nodes is a leaf node or external Subtree O – 2
node. Nodes that have children are known as internal nodes. Subtree N – 1
• A tree within a tree is considered a subtree.
• The level of a node is a measure of its distance from the root. Tree Traversal
• The depth of the tree is its highest level. • Traversal is the process of visiting all the nodes in a specific
• The degree is the number of child nodes in a subtree. order. The following are the different traversal types:
• Example: