Binary Tree in Data Structures
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
Introduction
 A binary tree is a hierarchical data structure in which
each node has at most two children generally referred
as left child and right child.
 Each node contains three components:
 Pointer to left subtree
 Pointer to right subtree
 Data element
Cont…
 The topmost node in the tree is called the root. An
empty tree is represented by NULL pointer.
 A representation of binary tree is shown:
Binary Tree
Important Terms
 Path − Path refers to the sequence of nodes along the
edges of a tree.
 Root − The node at the top of the tree is called root.
There is only one root per tree and one path from the
root node to any node.
 Parent − Any node except the root node has one edge
upward to a node called parent.
Cont..
 Child − The node below a given node connected by its
edge downward is called its child node.
 Leaf − The node which does not have any child node is
called the leaf node.
 Subtree − Subtree represents the descendants of a
node.
Cont..
 Visiting − Visiting refers to checking the value of a
node when control is on the node.
 Traversing − Traversing means passing through nodes
in a specific order.
 Levels − Level of a node represents the generation of a
node. If the root node is at level 0, then its next child
node is at level 1, its grandchild is at level 2, and so on.
Types of Binary Trees (Based on
Structure)
 Rooted binary tree: It has a root node and every
node has atmost two children.
 Full binary tree: It is a tree in which every node in the
tree has either 0 or 2 children.
Assignment
 Explain Binary Tree in data structure with suitable
example and discuss basic operation.

Binary tree in data structures

  • 1.
    Binary Tree inData Structures Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2.
    Introduction  A binarytree is a hierarchical data structure in which each node has at most two children generally referred as left child and right child.  Each node contains three components:  Pointer to left subtree  Pointer to right subtree  Data element
  • 3.
    Cont…  The topmostnode in the tree is called the root. An empty tree is represented by NULL pointer.  A representation of binary tree is shown:
  • 4.
  • 5.
    Important Terms  Path− Path refers to the sequence of nodes along the edges of a tree.  Root − The node at the top of the tree is called root. There is only one root per tree and one path from the root node to any node.  Parent − Any node except the root node has one edge upward to a node called parent.
  • 6.
    Cont..  Child −The node below a given node connected by its edge downward is called its child node.  Leaf − The node which does not have any child node is called the leaf node.  Subtree − Subtree represents the descendants of a node.
  • 7.
    Cont..  Visiting −Visiting refers to checking the value of a node when control is on the node.  Traversing − Traversing means passing through nodes in a specific order.  Levels − Level of a node represents the generation of a node. If the root node is at level 0, then its next child node is at level 1, its grandchild is at level 2, and so on.
  • 8.
    Types of BinaryTrees (Based on Structure)  Rooted binary tree: It has a root node and every node has atmost two children.  Full binary tree: It is a tree in which every node in the tree has either 0 or 2 children.
  • 9.
    Assignment  Explain BinaryTree in data structure with suitable example and discuss basic operation.