SlideShare a Scribd company logo
Representation of Binary tree
in memory
Let T be a binary.
There are two ways for representing binary
tree in memory.

Sequential Representation
Linked Representation
Sequential Representation
   Suppose T is a complete binary tree. Then
    only single linear array TREE is used as
    follows.
   The root R is stored in TREE[0].

   If a node n occupies TREE[K],

   then its left child in TREE[2*K]

   & right child TREE [2*K+1].

   If TREE[1]=NULL then it is empty
    tree.
Representation of binary tree in memory
Representation of binary tree in memory
Representation of binary tree in memory
Linked Representation
   The linked representation uses three parallel
    arrays,INFO,LEFT & RIGHT & a pointer variable
    ROOT.Each node N of Y will correspond to a location K
    such that:

   1) INFO[K] contains the data at node N.

   2) LEFT[K] contains the location of left child of node N.

   3) RIGHT[K] contains the location of right child of node
    N.

   ROOT will contain location of root R of T.
A sample representation is shown
in fig.
Ad

More Related Content

What's hot (20)

B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
Ashish Arun
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
ADDRESSING MODES
ADDRESSING MODESADDRESSING MODES
ADDRESSING MODES
Sadaf Rasheed
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 
Normalization 1 nf,2nf,3nf,bcnf
Normalization 1 nf,2nf,3nf,bcnf Normalization 1 nf,2nf,3nf,bcnf
Normalization 1 nf,2nf,3nf,bcnf
Shriya agrawal
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
srutisenpatra
 
Unit 1-Introduction to Data Structures-BCA.pdf
Unit 1-Introduction to Data Structures-BCA.pdfUnit 1-Introduction to Data Structures-BCA.pdf
Unit 1-Introduction to Data Structures-BCA.pdf
MaryJacob24
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
single linked list
single linked listsingle linked list
single linked list
Sathasivam Rangasamy
 
Heap tree
Heap treeHeap tree
Heap tree
JananiJ19
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
Decomposition methods in DBMS
Decomposition methods in DBMSDecomposition methods in DBMS
Decomposition methods in DBMS
soniyagoyal3
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
GirdharRatne
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Linked list implementation of Queue
Linked list implementation of QueueLinked list implementation of Queue
Linked list implementation of Queue
Dr. Sindhia Lingaswamy
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
Dr Sandeep Kumar Poonia
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
Protap Mondal
 

Viewers also liked (20)

Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
Aakash deep Singhal
 
Binary tree
Binary  treeBinary  tree
Binary tree
Vanitha Chandru
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
Trupti Agrawal
 
Binary tree
Binary treeBinary tree
Binary tree
Ssankett Negi
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Lovelyn Rose
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
khabbab_h
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Balanced binary search tree on array
Balanced binary search tree on array Balanced binary search tree on array
Balanced binary search tree on array
Pier Giuliano Nioi
 
16 Fibonacci Heaps
16 Fibonacci Heaps16 Fibonacci Heaps
16 Fibonacci Heaps
Andres Mendez-Vazquez
 
358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12
sumitbardhan
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
Waheed Khalid
 
Arrays
ArraysArrays
Arrays
SARITHA REDDY
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
Äshïsh Jäïn
 
Fibonacci Heap
Fibonacci HeapFibonacci Heap
Fibonacci Heap
Anshuman Biswal
 
Height measurement of tree.. forest mensration
Height measurement   of tree.. forest mensrationHeight measurement   of tree.. forest mensration
Height measurement of tree.. forest mensration
Manzoor Wani
 
Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
Aakash deep Singhal
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
Trupti Agrawal
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Lovelyn Rose
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
khabbab_h
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Balanced binary search tree on array
Balanced binary search tree on array Balanced binary search tree on array
Balanced binary search tree on array
Pier Giuliano Nioi
 
358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12
sumitbardhan
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
Waheed Khalid
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Height measurement of tree.. forest mensration
Height measurement   of tree.. forest mensrationHeight measurement   of tree.. forest mensration
Height measurement of tree.. forest mensration
Manzoor Wani
 
Ad

Similar to Representation of binary tree in memory (11)

Trees
TreesTrees
Trees
Speaking Technology
 
Unit 4 tree
Unit 4   treeUnit 4   tree
Unit 4 tree
kalyanineve
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
Abirami A
 
Tree
TreeTree
Tree
Rohan Chougule
 
Tree terminology and introduction to binary tree
Tree terminology and introduction to binary treeTree terminology and introduction to binary tree
Tree terminology and introduction to binary tree
jyoti_lakhani
 
non linear data structure -introduction of tree
non linear data structure -introduction of treenon linear data structure -introduction of tree
non linear data structure -introduction of tree
Siddhi Viradiya
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
maamir farooq
 
7.tree
7.tree7.tree
7.tree
Chandan Singh
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
Data Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer ScienceData Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer Science
ManishShukla712917
 
Hi please complete the following with detailed working out Find the .pdf
Hi please complete the following with detailed working out Find the .pdfHi please complete the following with detailed working out Find the .pdf
Hi please complete the following with detailed working out Find the .pdf
ezhilvizhiyan
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
Abirami A
 
Tree terminology and introduction to binary tree
Tree terminology and introduction to binary treeTree terminology and introduction to binary tree
Tree terminology and introduction to binary tree
jyoti_lakhani
 
non linear data structure -introduction of tree
non linear data structure -introduction of treenon linear data structure -introduction of tree
non linear data structure -introduction of tree
Siddhi Viradiya
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
maamir farooq
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
Data Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer ScienceData Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer Science
ManishShukla712917
 
Hi please complete the following with detailed working out Find the .pdf
Hi please complete the following with detailed working out Find the .pdfHi please complete the following with detailed working out Find the .pdf
Hi please complete the following with detailed working out Find the .pdf
ezhilvizhiyan
 
Ad

Representation of binary tree in memory

  • 1. Representation of Binary tree in memory Let T be a binary. There are two ways for representing binary tree in memory. Sequential Representation Linked Representation
  • 2. Sequential Representation  Suppose T is a complete binary tree. Then only single linear array TREE is used as follows.
  • 3. The root R is stored in TREE[0].  If a node n occupies TREE[K],  then its left child in TREE[2*K]  & right child TREE [2*K+1].  If TREE[1]=NULL then it is empty tree.
  • 7. Linked Representation  The linked representation uses three parallel arrays,INFO,LEFT & RIGHT & a pointer variable ROOT.Each node N of Y will correspond to a location K such that:  1) INFO[K] contains the data at node N.  2) LEFT[K] contains the location of left child of node N.  3) RIGHT[K] contains the location of right child of node N.  ROOT will contain location of root R of T.
  • 8. A sample representation is shown in fig.
  翻译: