SlideShare a Scribd company logo
DATA STRUCTURES

DEF:DS is a collection of
organized data that are related to
each other.
DATA STRUCTURES




     LINEAR DS                          NON-LINEAR




STACKS           QUEUES   LINKED LIST
                                          TREES      GRAPHS
TREES
 DEF:A TREE IS A SET OF NODES AND LINKS
 BINARY TREE:A BINARY TREE IS A FINITE SET OF ELEMENTS
  THAT IS EITHER EMPTY OR PARTITIONED INTO 3 DISJOINT
  SUBSETS .
 THE 1ST SUBSET CONTAINS A SINGLE ELEMENT CALLED AS
  “ROOT OF THE BINARY TREE”.THE OTHER TWO SUBSETS ARE
  THEMSELVES TREES CALLED LEFT AND RIGHT SUBTREES OF
  THE ORIGINAL TREE.
 EACH ELEMENT OF THE BINARY TREE IS CALLED “NODE” OF
  THE BINARY TREE.
A


          B                C



  D                    F           G
               E




LEFT SUBTREE
                           RIGHT SUBTREE
 In the above example A is the root node of
  the tree and B is the root of the left sub tree
  and C is the root of the right subtree.
 Then A is called as father of B and C.
 Where B is the left son of A and C is the
  right son of A.
TREE BASICS
   Number of nodes
   Height
   Root Node
   Leaves
   Interior nodes
   Number of levels
   Ancestors of H
   Descendants of B
   Siblings of E
   Right subtree
SIBLING
 If N is a node In T that has left sub tree S1,
  and a right sub tree S2, then N is called as
  the parent of the S1& S2
 So S1 &S2 are called siblings.
LEVEL NUMBER
 Every node in a tree is assigned a level
  number.
 The root is defined at level 0
 The left and right child of root node has
  level n0.1 and so on…………….
DEGREE
 The degree of the node is equal to the num
   ber of children that a node has.
     for eg: the degree of root node A is 2
IN DEGREE AND OUT DEGREE
 In in-degree of a node is the number of
  edges arriving at that node.
      for eg: the root node is the only node that
  has an in-degree 0.
 Similarly the out degree of a node is the
  number of edges that leaving the node.
Leaf(or)Leaf Node or Terminal node
 A “Node” that has no sons is called as “leaf
  node”
 In the above fig D,E,F&G are the leaf nodes
 Where A,B,C are the non leaf nodes

                           A


                   B                C



                       LEAF NODES
ANCESTOR
 A Node ‘n1’ is an ancestor of node ‘n2’ if
  ‘n1’ is neither father of ‘n2’(or) father of
  some ancestor of ‘n2’.              n1


                                         n2
                   n1


                             B



                        n2
 In the above fig 1 ‘n1’ is the father of ‘n2’ so
  directly we call ‘n1 as ancestor of ‘n2’
 In fig2 there is no direct relation ship b/w n1
  and n2 even though n1 Is the father of B
  where b is the father of n2 then we call n1
  as father of ancestor of ‘n2’ so n1 become
  ancestor of n2
Descendent
 A node ‘n2 is descendent of ‘n1’if ‘n2 is son
  of ‘n1’                              n1
 In the above fig directly n2 is the
                                             n2
 son of n1.
                                      n1
In fig2 n2 is the son of ‘b’ where
                                              b
B is the descendent of n1 the n2 is son of
  descendent of n1                        n2
Then n2 is descendent of n1.
Brother Nodes
 Two nodes are said to be brothers if they ae
  left and right sons of the same father node

                                   A




                            B              C
 The direction of travelling from roots to
  leaves is “down” and the travelling from
  leaves to root is up.
 Moving from leaves is known as “climbing”
 And moving from roots to leaves is also
  known as descending.
BINARY TREE
 A binary tree is a non-linear data structure
  which is defined as collection of elements
  called nodes.
 Every node has left pointer and right pointer
  and the data element.
 Every binary tree has a root node which is
  the top most node in the tree.
 If root is equal to null then the tree is empty.
1


            2                 3


                5        6        7
    4

                    10       11       12
8
        9
 In the above figure, node-2 is the left
  successor and node-3 is the right succesor
 Note that the left sub-tree of the root node
  consists of nodes-2,4,5,8,and 9. and right
  sub-tree consists of nodes-3,6,7,10,11,12
 The leaf nodes are 5,8,9,10,11,12.
Properties of BinaryTree
 Property1:A tree with ‘n’ nodes has exactly
  n-1 edges or branches.
 Property2:In a tree every node except the
  root has exactly 1 parent
 Property3:There is exactly one path
  connecting any 2 nodes in a tree.
 Property4:the max no of nodes in a binary
  tree of height k is 2k+1 -1 (k>=0)
 Property5:Btree with n internal nodes has
  n+1 external nodes.
Strict Binary Tree
 If every non leaf node in the binary tree
  having non empty left and right sub trees
  then it is known as strict binary trees
 In a binary tree if every non-leaf node
  having both left and right sons then it is
  called as strict binary tree.
A


        B                       C


                F           G           H
E




                    A
    B                           C

                    D               E

            F
 In the above fig1 is a strict binary tree where
  as fig2 is not because the non leaf node D
  having only leftson ‘F’ it doesnot have right
  son.
 So in a strict binary tree with n leaves totally
  we have (2n-1) nodes.
 Ie from the above fig we have 4 leaf nodes
  the n we have (2*4-1)=7
Level of the node:
 The level of the node in a binary tree is
  defined as follows.
 The root of the binary tree always having
  level ’0’ and the level of any other node is
  one more that its father node.
 Level of a node=1+its father node level
LEVEL 0
               A



                                     LEVEL 1
 B                     C




     LEVEL 2       D             E




LEVEL3         E
DEPTH OF BT
 The depth of bt is the max level of any leaf
  node in that tree.         A
                                        LEVEL0

                                               LEVEL1
                          B               C


                     LEVEL2       D                E


                 LEVEL3       F



                                      G   LEVEL4
   LEVEL:4
   DEPTH=4
   Depth always equals to length of longest
    path from root to leaves
Complete BTree
 A complete Btree of Depth “D” is a strict
  Btree whose all leaf nodes must exist at
  level”D”.
REPRESENTATION OF B TREE
     USING ARRAYS
 Suppose T is a Binary tree that is complete.
  there is an efficient way of maintaining T
  in memory called Sequential representation
  of T.
The representation uses only a single linear
  array tree as follows.
a)The root R of tree T is stored in Tree[i]
b)If a node N occupies Tree[K],then the left
  child is stored in Tree[2k+1] and right child
  is stored in Tree[2k+2].

                    Complete trees in arrays:
              Storage of complete
                                  Trees
                                   0
                                  1 2
                                3 4 5 6
                            7 8



                    …


          0     1       2   3      4      5   6   7    8


                            k=3                   2k+1, 2k+2

CIS 068
Sequential                                                   [1]
                                                                 [2]
                                                                       A

                                                                 [3]   B
    Representation                                               [4]
                                                                 [5]   C
                                    (1) waste space
                A   [1]    A                                     [6]
                                    (2) insertion/deletion
                    [2]    B                                     [7]   D
                                        problem
                    [3]    --                                    [8]
            B       [4]                                          [9]   E
                    [5]    C
                                                  A
                    [6]    --                                          F
                    [7]    --                                          H
        C
                    [8]
                    [9]    --           B                              I
                                                             C
    D               .      D
                    [16]   --
                           .
                           E        D        E        F            G
E



                                H        I
REPRESENTATION OF B TREE
    USING LINKED LIST
Data Structures: A
Pseudocode Approach
with C                36
Operations on BT

There are 3 important operations
             on BT.
            Insertion
            Deletion
           Searching

More Related Content

Similar to Data structures

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
 
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
 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
DhanushSrinivasulu
 
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptxLecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
HamzaUsman48
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
Dabbal Singh Mahara
 
Unit – vi tree
Unit – vi   treeUnit – vi   tree
Unit – vi tree
Tribhuvan University
 
7.tree
7.tree7.tree
07 trees
07 trees07 trees
07 trees
Rajan Gautam
 
Tree
TreeTree
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
 
09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
Tech_MX
 
Trees
TreesTrees
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
smruti sarangi
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Chapter 5_Trees.pdf
Chapter 5_Trees.pdfChapter 5_Trees.pdf
Chapter 5_Trees.pdf
ssuser50179b
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
Abirami A
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
Muhazzab Chouhadry
 
Chapter 8 ds
Chapter 8 dsChapter 8 ds
Chapter 8 ds
Hanif Durad
 
Tree
TreeTree
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
Om Prakash
 

Similar to Data structures (20)

Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
 
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
 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
 
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptxLecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
 
Unit – vi tree
Unit – vi   treeUnit – vi   tree
Unit – vi tree
 
7.tree
7.tree7.tree
7.tree
 
07 trees
07 trees07 trees
07 trees
 
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
 
09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
 
Trees
TreesTrees
Trees
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
Chapter 5_Trees.pdf
Chapter 5_Trees.pdfChapter 5_Trees.pdf
Chapter 5_Trees.pdf
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Chapter 8 ds
Chapter 8 dsChapter 8 ds
Chapter 8 ds
 
Tree
TreeTree
Tree
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 

More from IIUI

Rank brain
Rank brainRank brain
Rank brain
IIUI
 
Chapter 10 cs 2o-p
Chapter 10 cs 2o-pChapter 10 cs 2o-p
Chapter 10 cs 2o-p
IIUI
 
Chapter 09 io devices 3o-p
Chapter 09 io devices 3o-pChapter 09 io devices 3o-p
Chapter 09 io devices 3o-p
IIUI
 
Chapter 09 io devices 2o-p
Chapter 09 io devices 2o-pChapter 09 io devices 2o-p
Chapter 09 io devices 2o-p
IIUI
 
Chapter 09 io devices
Chapter 09 io devicesChapter 09 io devices
Chapter 09 io devices
IIUI
 
Chapter 08 secondary storage 3o-p
Chapter 08 secondary storage 3o-pChapter 08 secondary storage 3o-p
Chapter 08 secondary storage 3o-p
IIUI
 
Chapter 08 secondary storage 2o-p
Chapter 08 secondary storage 2o-pChapter 08 secondary storage 2o-p
Chapter 08 secondary storage 2o-p
IIUI
 
Chapter 08 secondary storage
Chapter 08 secondary storageChapter 08 secondary storage
Chapter 08 secondary storage
IIUI
 
Chapter 07 pam 3o-p
Chapter 07 pam 3o-pChapter 07 pam 3o-p
Chapter 07 pam 3o-p
IIUI
 
Chapter 07 pam 2o-p
Chapter 07 pam 2o-pChapter 07 pam 2o-p
Chapter 07 pam 2o-p
IIUI
 
Chapter 07 pam
Chapter 07 pamChapter 07 pam
Chapter 07 pam
IIUI
 
Chapter 06 boolean algebra 3o-p
Chapter 06 boolean algebra 3o-pChapter 06 boolean algebra 3o-p
Chapter 06 boolean algebra 3o-p
IIUI
 
Chapter 06 boolean algebra 2o-p
Chapter 06 boolean algebra 2o-pChapter 06 boolean algebra 2o-p
Chapter 06 boolean algebra 2o-p
IIUI
 
Chapter 06 boolean algebra
Chapter 06 boolean algebraChapter 06 boolean algebra
Chapter 06 boolean algebra
IIUI
 
Chapter 05 computer arithmetic 2o-p
Chapter 05 computer arithmetic 2o-pChapter 05 computer arithmetic 2o-p
Chapter 05 computer arithmetic 2o-p
IIUI
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
IIUI
 
Chapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-pChapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-p
IIUI
 
Chapter 04 computer codes
Chapter 04 computer codesChapter 04 computer codes
Chapter 04 computer codes
IIUI
 
Chapter 03 number system 3o-p
Chapter 03 number system 3o-pChapter 03 number system 3o-p
Chapter 03 number system 3o-p
IIUI
 
Chapter 03 number system 2o-p
Chapter 03 number system 2o-pChapter 03 number system 2o-p
Chapter 03 number system 2o-p
IIUI
 

More from IIUI (20)

Rank brain
Rank brainRank brain
Rank brain
 
Chapter 10 cs 2o-p
Chapter 10 cs 2o-pChapter 10 cs 2o-p
Chapter 10 cs 2o-p
 
Chapter 09 io devices 3o-p
Chapter 09 io devices 3o-pChapter 09 io devices 3o-p
Chapter 09 io devices 3o-p
 
Chapter 09 io devices 2o-p
Chapter 09 io devices 2o-pChapter 09 io devices 2o-p
Chapter 09 io devices 2o-p
 
Chapter 09 io devices
Chapter 09 io devicesChapter 09 io devices
Chapter 09 io devices
 
Chapter 08 secondary storage 3o-p
Chapter 08 secondary storage 3o-pChapter 08 secondary storage 3o-p
Chapter 08 secondary storage 3o-p
 
Chapter 08 secondary storage 2o-p
Chapter 08 secondary storage 2o-pChapter 08 secondary storage 2o-p
Chapter 08 secondary storage 2o-p
 
Chapter 08 secondary storage
Chapter 08 secondary storageChapter 08 secondary storage
Chapter 08 secondary storage
 
Chapter 07 pam 3o-p
Chapter 07 pam 3o-pChapter 07 pam 3o-p
Chapter 07 pam 3o-p
 
Chapter 07 pam 2o-p
Chapter 07 pam 2o-pChapter 07 pam 2o-p
Chapter 07 pam 2o-p
 
Chapter 07 pam
Chapter 07 pamChapter 07 pam
Chapter 07 pam
 
Chapter 06 boolean algebra 3o-p
Chapter 06 boolean algebra 3o-pChapter 06 boolean algebra 3o-p
Chapter 06 boolean algebra 3o-p
 
Chapter 06 boolean algebra 2o-p
Chapter 06 boolean algebra 2o-pChapter 06 boolean algebra 2o-p
Chapter 06 boolean algebra 2o-p
 
Chapter 06 boolean algebra
Chapter 06 boolean algebraChapter 06 boolean algebra
Chapter 06 boolean algebra
 
Chapter 05 computer arithmetic 2o-p
Chapter 05 computer arithmetic 2o-pChapter 05 computer arithmetic 2o-p
Chapter 05 computer arithmetic 2o-p
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
 
Chapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-pChapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-p
 
Chapter 04 computer codes
Chapter 04 computer codesChapter 04 computer codes
Chapter 04 computer codes
 
Chapter 03 number system 3o-p
Chapter 03 number system 3o-pChapter 03 number system 3o-p
Chapter 03 number system 3o-p
 
Chapter 03 number system 2o-p
Chapter 03 number system 2o-pChapter 03 number system 2o-p
Chapter 03 number system 2o-p
 

Recently uploaded

BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 

Recently uploaded (20)

BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 

Data structures

  • 1. DATA STRUCTURES DEF:DS is a collection of organized data that are related to each other.
  • 2. DATA STRUCTURES LINEAR DS NON-LINEAR STACKS QUEUES LINKED LIST TREES GRAPHS
  • 3. TREES  DEF:A TREE IS A SET OF NODES AND LINKS  BINARY TREE:A BINARY TREE IS A FINITE SET OF ELEMENTS THAT IS EITHER EMPTY OR PARTITIONED INTO 3 DISJOINT SUBSETS .  THE 1ST SUBSET CONTAINS A SINGLE ELEMENT CALLED AS “ROOT OF THE BINARY TREE”.THE OTHER TWO SUBSETS ARE THEMSELVES TREES CALLED LEFT AND RIGHT SUBTREES OF THE ORIGINAL TREE.  EACH ELEMENT OF THE BINARY TREE IS CALLED “NODE” OF THE BINARY TREE.
  • 4. A B C D F G E LEFT SUBTREE RIGHT SUBTREE
  • 5.  In the above example A is the root node of the tree and B is the root of the left sub tree and C is the root of the right subtree.  Then A is called as father of B and C.  Where B is the left son of A and C is the right son of A.
  • 6. TREE BASICS  Number of nodes  Height  Root Node  Leaves  Interior nodes  Number of levels  Ancestors of H  Descendants of B  Siblings of E  Right subtree
  • 7.
  • 8. SIBLING  If N is a node In T that has left sub tree S1, and a right sub tree S2, then N is called as the parent of the S1& S2  So S1 &S2 are called siblings.
  • 9. LEVEL NUMBER  Every node in a tree is assigned a level number.  The root is defined at level 0  The left and right child of root node has level n0.1 and so on…………….
  • 10. DEGREE  The degree of the node is equal to the num ber of children that a node has. for eg: the degree of root node A is 2
  • 11. IN DEGREE AND OUT DEGREE  In in-degree of a node is the number of edges arriving at that node. for eg: the root node is the only node that has an in-degree 0.  Similarly the out degree of a node is the number of edges that leaving the node.
  • 12. Leaf(or)Leaf Node or Terminal node  A “Node” that has no sons is called as “leaf node”  In the above fig D,E,F&G are the leaf nodes  Where A,B,C are the non leaf nodes A B C LEAF NODES
  • 13. ANCESTOR  A Node ‘n1’ is an ancestor of node ‘n2’ if ‘n1’ is neither father of ‘n2’(or) father of some ancestor of ‘n2’. n1 n2 n1 B n2
  • 14.  In the above fig 1 ‘n1’ is the father of ‘n2’ so directly we call ‘n1 as ancestor of ‘n2’  In fig2 there is no direct relation ship b/w n1 and n2 even though n1 Is the father of B where b is the father of n2 then we call n1 as father of ancestor of ‘n2’ so n1 become ancestor of n2
  • 15. Descendent  A node ‘n2 is descendent of ‘n1’if ‘n2 is son of ‘n1’ n1  In the above fig directly n2 is the n2 son of n1. n1 In fig2 n2 is the son of ‘b’ where b B is the descendent of n1 the n2 is son of descendent of n1 n2 Then n2 is descendent of n1.
  • 16. Brother Nodes  Two nodes are said to be brothers if they ae left and right sons of the same father node A B C
  • 17.  The direction of travelling from roots to leaves is “down” and the travelling from leaves to root is up.  Moving from leaves is known as “climbing”  And moving from roots to leaves is also known as descending.
  • 18. BINARY TREE  A binary tree is a non-linear data structure which is defined as collection of elements called nodes.  Every node has left pointer and right pointer and the data element.  Every binary tree has a root node which is the top most node in the tree.  If root is equal to null then the tree is empty.
  • 19. 1 2 3 5 6 7 4 10 11 12 8 9
  • 20.  In the above figure, node-2 is the left successor and node-3 is the right succesor  Note that the left sub-tree of the root node consists of nodes-2,4,5,8,and 9. and right sub-tree consists of nodes-3,6,7,10,11,12  The leaf nodes are 5,8,9,10,11,12.
  • 21. Properties of BinaryTree  Property1:A tree with ‘n’ nodes has exactly n-1 edges or branches.  Property2:In a tree every node except the root has exactly 1 parent  Property3:There is exactly one path connecting any 2 nodes in a tree.  Property4:the max no of nodes in a binary tree of height k is 2k+1 -1 (k>=0)  Property5:Btree with n internal nodes has n+1 external nodes.
  • 22. Strict Binary Tree  If every non leaf node in the binary tree having non empty left and right sub trees then it is known as strict binary trees  In a binary tree if every non-leaf node having both left and right sons then it is called as strict binary tree.
  • 23. A B C F G H E A B C D E F
  • 24.  In the above fig1 is a strict binary tree where as fig2 is not because the non leaf node D having only leftson ‘F’ it doesnot have right son.  So in a strict binary tree with n leaves totally we have (2n-1) nodes.  Ie from the above fig we have 4 leaf nodes the n we have (2*4-1)=7
  • 25. Level of the node:  The level of the node in a binary tree is defined as follows.  The root of the binary tree always having level ’0’ and the level of any other node is one more that its father node.  Level of a node=1+its father node level
  • 26. LEVEL 0 A LEVEL 1 B C LEVEL 2 D E LEVEL3 E
  • 27. DEPTH OF BT  The depth of bt is the max level of any leaf node in that tree. A LEVEL0 LEVEL1 B C LEVEL2 D E LEVEL3 F G LEVEL4
  • 28. LEVEL:4  DEPTH=4  Depth always equals to length of longest path from root to leaves
  • 29. Complete BTree  A complete Btree of Depth “D” is a strict Btree whose all leaf nodes must exist at level”D”.
  • 30. REPRESENTATION OF B TREE USING ARRAYS
  • 31.  Suppose T is a Binary tree that is complete. there is an efficient way of maintaining T in memory called Sequential representation of T. The representation uses only a single linear array tree as follows. a)The root R of tree T is stored in Tree[i] b)If a node N occupies Tree[K],then the left child is stored in Tree[2k+1] and right child is stored in Tree[2k+2].
  • 32. Complete trees in arrays: Storage of complete Trees 0 1 2 3 4 5 6 7 8 … 0 1 2 3 4 5 6 7 8 k=3 2k+1, 2k+2 CIS 068
  • 33. Sequential [1] [2] A [3] B Representation [4] [5] C (1) waste space A [1] A [6] (2) insertion/deletion [2] B [7] D problem [3] -- [8] B [4] [9] E [5] C A [6] -- F [7] -- H C [8] [9] -- B I C D . D [16] -- . E D E F G E H I
  • 34. REPRESENTATION OF B TREE USING LINKED LIST
  • 35.
  • 36. Data Structures: A Pseudocode Approach with C 36
  • 37. Operations on BT There are 3 important operations on BT. Insertion Deletion Searching

Editor's Notes

  1. de