SlideShare ist ein Scribd-Unternehmen logo
1 von 8
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.
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.

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
FORESTS
FORESTSFORESTS
FORESTS
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
 
Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
 
Arrays
ArraysArrays
Arrays
 
Linked lists
Linked listsLinked lists
Linked lists
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
single linked list
single linked listsingle linked list
single linked list
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
 
Linked list
Linked listLinked list
Linked list
 

Andere mochten auch

Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsAakash deep Singhal
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)Trupti Agrawal
 
Trees data structure
Trees data structureTrees data structure
Trees data structureSumit 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 Treekhabbab_h
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary treeZaid Shabbir
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingEduardo Bergavera
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
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-12sumitbardhan
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory MappingQundeel
 
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 mensrationManzoor Wani
 

Andere mochten auch (20)

Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
Binary tree
Binary treeBinary tree
Binary tree
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
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)
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Balanced binary search tree on array
Balanced binary search tree on array Balanced binary search tree on array
Balanced binary search tree on array
 
16 Fibonacci Heaps
16 Fibonacci Heaps16 Fibonacci Heaps
16 Fibonacci Heaps
 
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
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Fibonacci Heap
Fibonacci HeapFibonacci Heap
Fibonacci Heap
 
Height measurement of tree.. forest mensration
Height measurement   of tree.. forest mensrationHeight measurement   of tree.. forest mensration
Height measurement of tree.. forest mensration
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 

Ähnlich wie Representation of binary tree in memory

Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptxAbirami 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 treejyoti_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 treeSiddhi Viradiya
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures treemaamir 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-10sumitbardhan
 
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 .pdfezhilvizhiyan
 

Ähnlich wie Representation of binary tree in memory (10)

Trees
TreesTrees
Trees
 
Unit 4 tree
Unit 4   treeUnit 4   tree
Unit 4 tree
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
Tree
TreeTree
Tree
 
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
 
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
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 
7.tree
7.tree7.tree
7.tree
 
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
 
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
 

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.
  • 4.
  • 5.
  • 6.
  • 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.