Tree Data Structure
Tree Data Structure
Tree Data Structure
A Tree
Different tree data structures allow quicker and easier access to the data as it
is a non-linear data structure.
Tree Terminologies
Node
A node is an entity that contains a key or value and pointers to its child nodes.
The last nodes of each path are called leaf nodes or external nodes that do
not contain a link/pointer to child nodes.
The node having at least a child node is called an internal node.
Edge
Height of a Node
The height of a node is the number of edges from the node to the deepest leaf
(ie. the longest path from the node to a leaf node).
Depth of a Node
The depth of a node is the number of edges from the root to the node.
Height of a Tree
The height of a Tree is the height of the root node or the depth of the deepest
node.
Forest
Types of Tree
1. Binary Tree
2. Binary Search Tree
3. AVL Tree
4. B-Tree
Tree Traversal
In order to perform any operation on a tree, you need to reach to the specific
node. The tree traversal algorithm helps in visiting a required node in the tree.
Most popular databases use B-Trees and T-Trees, which are variants of the
tree structure we learned above to store their data
Compilers use a syntax tree to validate the syntax of every program you write.