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?

Graph representation
Graph representationGraph representation
Graph representation
Tech_MX
 

Was ist angesagt? (20)

Complements
ComplementsComplements
Complements
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Graph representation
Graph representationGraph representation
Graph representation
 
Linked list
Linked listLinked list
Linked list
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Insertion in singly linked list
Insertion in singly linked listInsertion in singly linked list
Insertion in singly linked list
 
AVL Tree Data Structure
AVL Tree Data StructureAVL Tree Data Structure
AVL Tree Data Structure
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Arrays
ArraysArrays
Arrays
 
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)
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Hashing
HashingHashing
Hashing
 
Array operations
Array operationsArray operations
Array operations
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Digital principles basic
Digital principles basicDigital principles basic
Digital principles basic
 
Query processing
Query processingQuery processing
Query processing
 

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 algorithms
Aakash deep Singhal
 
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
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 

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 tree
Binary  treeBinary  tree
Binary tree
 
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)
 
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
 
Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)
 

Ähnlich wie Representation of binary tree in memory

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
 
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
 

Ä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.