Professional Documents
Culture Documents
Tree Data Structure
Tree Data Structure
A tree is a hierarchical data structure that consists of nodes connected by edges. It resembles the
hierarchical structure of natural trees.
Key properties:
o Each node has zero or more child nodes.
o The topmost node is called the root.
o Nodes can have their own subtrees (which are also trees).
Trees are used for organizing and representing data in a way that facilitates efficient navigation
and search.
Binary Tree
A binary tree is a special type of tree where each node has at most two children: a left child and
a right child.
Common operations: insertion, deletion, and traversal.
Balanced Binary Tree: Ensures that the difference in heights between left and right subtrees is at
most one.
Rules:
1. The root of the binary tree is the root of the general tree.
2. Left child of a node in the general tree becomes the left child in the binary tree.
3. Right sibling of any node in the general tree becomes the right child in the binary tree.
Example:
Rotation of Tree
AVL Tree
Graphs
Graphs consist of nodes (vertices) and edges connecting them.
Types: directed, undirected, weighted, unweighted.
Applications: social networks, transportation networks, etc.