Tree and Graph
Tree and Graph
BY
ATTIA AGHA
Introduction to tree data structure
Tree data structure can be classified into three types based upon the
number of children each node of the tree can have. The types are:
Binary tree: In a binary tree, each node can have a maximum of two
children linked to it. Some common types of binary trees include full
binary trees, complete binary trees, balanced binary trees, and
degenerate or pathological binary trees. Examples of Binary Tree are
Binary Search Tree and Binary Heap.
Ternary Tree: A Ternary Tree is a tree data structure in which each node
has at most three child nodes, usually distinguished as “left”, “mid” and
“right”.
N-ary Tree or Generic Tree: Generic trees are a collection of nodes
where each node is a data structure that consists of records and a list of
references to its children(duplicate references are not allowed). Unlike the
linked list, each node stores the address of multiple nodes.
Basic Operations Of Tree Data
Structure:
Create – create a tree in the data structure.
Insert − Inserts data in a tree.
Search − Searches specific data in a tree to check whether it is
present or not.
Traversal:
Depth-First-Search Traversal
Breadth-First-Search Traversal
Graph