Data Structures
Data Structures
Warang
A data structure is a particular way of storing and organizing
data in a computer so that it can be used efficiently.
Module A
Module B
Module C
.
.
.
Conditional flow (Selection Logic)
One or more modules(set of steps) are selected
depending on condition.
Pointer to an array:
• Pointer to an array is a pointer variable which holds the address of
the element in the array.
Example –
• An array of 8 pointers to float
float *a[8];
The binary tree has 9 nodes (A to I). Root A is at the top of the tree.
• Left successor – B is the left successor of node A.
• Right successor – C is the right successor of node A.
• Left subtree – Left subtree consists of nodes B,D,E,G.
• Right subtree – Right subtree consists of nodes C,F,H,I.
• Terminal node – The node with no successor is called terminal node. D,G,H,I
are terminal nodes.
Any node N in a binary tree T has either 0,1 or 2
successors.
Relation between total no. of nodes & depth of
Binary Tree
Types of Binary tree
• Complete Binary Tree - A complete
binary tree is a binary tree in which all the
levels are completely filled except possibly
the lowest one, which is filled from the left.
• Extended binary tree or 2-tree –
Extended binary tree is a binary tree in
which every node has 0 or 2 children. The
nodes with 2 children are called internal
nodes. The nodes with 0 children are called
external nodes.
• Binary search tree – Binary search tree is
a binary tree in which each node N has the
property that its value is greater than every
node value in left subtree of N and is less
than or equal to every node value in right
subtree of N
Representation of Binary tree in Memory
Representation of Binary tree in Memory
Drawing a Binary tree for given expression
Drawing a Binary tree for given expression