Tree Data Structure
Tree Data Structure
2. Edge
3. Root
4. Height of a Node
7. Degree of a Node
8. Forest
A collection of disjoint trees is called a forest. You can
create a forest by cutting the root of a tree.
Creating forest from a tree
BST Basic Operations
The basic operations that can be performed on a binary
search tree data structure, are the following −
•Insert − Inserts an element in a tree/create a tree.
1. Inorder
2. Preorder
3. postorder
Inorder Traversal
D→B→E→A→F→C→G
Preorder Traversal
In this traversal method, the root node is visited first,
then the left subtree and finally the right subtree.
We start from A, and
following pre-order
traversal, we first
visit A itself and then move
to its left subtree B. B is
also traversed pre-order.
The process goes on until
all the nodes are visited.
The output of pre-order
traversal of this tree will be
A→B→D→E→C→F→G
1.Visit root node
D→E→B→F→G→C→A
Types of Trees in Data Structure
1. General Tree