SlideShare a Scribd company logo
1 of 43
Data Structures and Algorithms
Unit - II
Unit II
Trees – Binary tree representations – Tree
Traversal – Threaded Binary Trees – Binary Tree
Representation of Trees – Graphs and
Representations – Traversals, Connected
Components and Spanning Trees – Shortest
Paths and Transitive closure – Activity Networks –
Topological Sort and Critical Paths.
• Atree is an abstract model of ahierarchical structure that consistsof
nodes with aparent-child relationship.
• Treeis asequence of nodes
• There is astarting node known asaroot node
• Everynode other than the root hasaparentnode.
• Nodes mayhaveany number of children
• Root −Node at the top of the treeis called root.
• Parent −Any node except root node has one edge upward to a node called parent.
• Child − Node below agiven node connected by its edge downward is called its child node.
• Sibling – Child of same node are called siblings
• Leaf −Node which does not have any child node is called leaf node.
• Subtree −Subtree represents descendants of a node.
• Levels −Level of anode represents the generation of anode. If root node is at level 0, then
itsnext child node is at level 1, its grandchild is at level 2 and soon.
• keys−Keyrepresents avalue of anode based on which asearch operation is to be carried
out for anode.
• Degree of anode:
• Thedegree of anode is the number of children of that node
• Degree of aTree:
• Thedegree of atree is the maximum degree of nodes in agiventree
• Path:
• It is the sequence of consecutive edges from source node to destination node.
• Height of anode:
• Theheight of anode is the maxpath length form that node to aleaf node.
• Height of atree:
• Theheight of atree is the height ofthe root
• Depth of atree:
• Depth of atree is the maxlevel of any leaf in the tree
• Non-linear data structure
• Combinesadvantages of an ordered array
• Searchingasfast asin ordered array
• Insertion and deletion asfast asin linked list
• Simple and fast
• Directory structure of afile store
• Structure of an arithmetic expressions
• Used in almost every 3D video game to determine what
objects need to be rendered.
• Used in almost every high-bandwidth router for storingrouter-
tables.
• used in compression algorithms, such asthose used by the .jpeg
and .mp3 file- formats.
• Abinary tree, is atree in which no node canhavemore than two
children.
• Consider abinary tree T
,here ‘A’is the root node of the binary treeT
.
• ‘B’ is the left child of ‘A’and ‘C’is theright
child of ‘A’
• i.e Ais afather of BandC.
• Thenode Band Care called siblings.
• Nodes D,H,I,F
,Jare leafnode
• Abinary tree, T,is either empty or suchthat
III.
I. Thasaspecial node called the root node
II. Thastwo sets of nodes L
Tand RT
,called the left subtree and right subtree of
T, respectively.
L
Tand RTare binarytrees.
• Abinary tree is a finite set of elements that are either empty or is
partitioned into three disjointsubsets.
• Thefirst subset contains asingle element called the root of the tree.
• Theother two subsets are themselves binary trees called the left and right
sub-trees of the originaltree.
• Aleft or right sub-tree canbeempty.
• Eachelement of abinary tree is called anode of thetree.
• Theroot node of this binary tree isA.
• Theleft sub tree of the root node, which we denoted by LA,is theset
LA ={B,D,E,G}and the right sub tree of the root node, RAis the set
RA={C,F
,H}
• Theroot node of LAis node B,the root node of RAis Cand soon
• Complete binary tree
• Strictly binary tree
• Almost complete binary tree
• If every non-leaf node in abinary tree hasnonempty leftand right sub-trees, then
suchatree is called astrictly binarytree.
• Or,to put it another way,all of the nodes in astrictly binary tree are of degree zero
or two, never degreeone.
• Astrictly binary tree with
Nleavesalwayscontains 2N– 1 nodes.
• Acompletebinarytree is abinarytree in which every level, except possiblythe last, is completely
filled, and all nodes are asfar leftaspossible.
• Acompletebinarytreeof depth d is called strictly binary tree if all of whose leavesare at level d.
• Acomplete binary tree has2d nodes at every depthd and 2d -1 non leaf nodes
• Analmost complete binary tree is atree where for aright child, thereis alwaysa
left child, but for aleft child there may not be aright child.
• Traversalis aprocessto visit all the nodes of atree and mayprinttheir
values too.
• All nodes are connected via edges(links) we alwaysstart from theroot
(head)node.
• There are three wayswhich we useto traverse atree
• In-orderTraversal
• Pre-orderTraversal
• Post-orderTraversal
• Generally we traverse atree to search or locate given item or keyin the tree
or to print all the values it contains.
• Pre-order
<root><left><right>
• In-order
<left><root><right>
• Post-order
<left><right><root>
• Thepreorder traversal of anonempty binary tree is defined asfollows:
• Visit the root node
• Traversethe left sub-tree inpreorder
• Traversethe right sub-tree inpreorder
• Thein-order traversal of anonempty binary tree is defined asfollows:
• Traversethe left sub-tree inin-order
• Visit the root node
• Traversethe right sub-tree ininorder
• Thein-order traversal output
of the given treeis
H D I B E A F C G
• Thein-order traversal of anonempty binary tree is defined asfollows:
• Traversethe left sub-tree inpost-order
• Traversethe right sub-tree inpost-order
• Visit the root node
• Thein-order traversal output
of the given treeis
H I D E B F G C A
• A binary search tree (BST) is a binary tree that is either empty or in
which every node contains a key (value) and satisfies the following
conditions:
• All keys in the left sub-tree of the root are smaller than the key in the root
node
• All keysin the right sub-tree of the root are greater than the keyin the root
node
• Theleft and right sub-trees of the root are again binary search trees
• Abinary search tree is basically abinary tree, and therefore it canbe
traversed in inorder, preorder andpostorder.
• If we traverse abinary search tree in inorder and print the identifiers
contained in the nodes of the tree, we get asorted list of identifiers in
ascending order.
• Following operations canbe done in BST
:
• Search(k,T):Searchfor keyk in the tree T
.If k is found in somenode oftree
then return true otherwise returnfalse.
• Insert(k,T):Insert anew node with value k in the info field in the tree Tsuch
that the property of BSTismaintained.
• Delete(k, T):Delete anode with value k in the info field from the tree Tsuch
that the property of BSTismaintained.
• FindMin(T), FindMax(T): Find minimum and maximum element from the
given nonempty BST
.
Graph is a non Linear Data structure which is a collection of two finite sets of V & E
Where V is vertices(node) and E is Edges (arcs)
i.e. G = (V, E)
Where V = {A, B, C, D, E, F} &
E = { (A, B}, (A,C), (B,C), (B,D), (C,D), (C,E), (D,E), (D,F), (E,F)}
The pair (A,B) defines an edge between A and B.
A
E.g. B D
C E F
The number of vertices of graph constitute the order of graph. Hence In given
Example the order of graph is Six
1. Adjacent vertices: Two vertices are said to be adjacent if they are connected by an edge.
e.g. B & C
2. Adjacent Edges: Two edges are said to be adjacent if they are incident on the common
vertex.
e.g. CD & CE.
3. Path: A Path is a sequence of distinct vertices in which each vertex is adjacent to next one.
e.g. ABCDEF
4. Cycle: A cycle is a path consisting of at least three vertices where last vertex is adjacent to
the first vertex.
e.g. C D F E C
5. Loop: It is special cycle that start and end with same vertex without visiting any other vertex.
6. Degree of Vertex: The degree of a vertex is the number of lines incident on it
e.g. degree of D is 4
7. Out-Degree: The out Degree of directed graph is the number of arcs leaving the vertex.
8. In-Degree: In degree of directed graph is number of arcs entering the vertex.
9. Multiple Edges: The distinct parallel edges that connect the same end point.2
Binary Tree Traversal and Graph Representations
Binary Tree Traversal and Graph Representations
Binary Tree Traversal and Graph Representations
Binary Tree Traversal and Graph Representations
Binary Tree Traversal and Graph Representations
Binary Tree Traversal and Graph Representations
Binary Tree Traversal and Graph Representations

More Related Content

Similar to Binary Tree Traversal and Graph Representations

Introduction to tree ds
Introduction to tree dsIntroduction to tree ds
Introduction to tree dsViji B
 
Lecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptxLecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptxfizzaahmed9
 
Bsc cs ii dfs u-3 tree and graph
Bsc cs  ii dfs u-3 tree and graphBsc cs  ii dfs u-3 tree and graph
Bsc cs ii dfs u-3 tree and graphRai University
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graphRai University
 
Mca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphMca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphRai University
 
Tree Introduction.pptx
Tree Introduction.pptxTree Introduction.pptx
Tree Introduction.pptxRahulAI
 
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
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap treezia eagle
 
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
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptxAbirami A
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxRajitha Reddy Alugati
 
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptxTERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptxKALPANAC20
 

Similar to Binary Tree Traversal and Graph Representations (20)

Data Structures 4
Data Structures 4Data Structures 4
Data Structures 4
 
Introduction to tree ds
Introduction to tree dsIntroduction to tree ds
Introduction to tree ds
 
Lecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptxLecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptx
 
Module - 5_Trees.pdf
Module - 5_Trees.pdfModule - 5_Trees.pdf
Module - 5_Trees.pdf
 
Unit – vi tree
Unit – vi   treeUnit – vi   tree
Unit – vi tree
 
Tree 11.ppt
Tree 11.pptTree 11.ppt
Tree 11.ppt
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Bsc cs ii dfs u-3 tree and graph
Bsc cs  ii dfs u-3 tree and graphBsc cs  ii dfs u-3 tree and graph
Bsc cs ii dfs u-3 tree and graph
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graph
 
Mca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphMca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graph
 
Tree Introduction.pptx
Tree Introduction.pptxTree Introduction.pptx
Tree Introduction.pptx
 
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
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Tree chapter
Tree chapterTree chapter
Tree chapter
 
Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
 
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptxTERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
 

More from SeethaDinesh

Input Devices.pptx
Input Devices.pptxInput Devices.pptx
Input Devices.pptxSeethaDinesh
 
Generations of Computers.ppt
Generations of Computers.pptGenerations of Computers.ppt
Generations of Computers.pptSeethaDinesh
 
Inheritance in java.ppt
Inheritance in java.pptInheritance in java.ppt
Inheritance in java.pptSeethaDinesh
 
Arrays in JAVA.ppt
Arrays in JAVA.pptArrays in JAVA.ppt
Arrays in JAVA.pptSeethaDinesh
 
PROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptxPROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptxSeethaDinesh
 
Cloud Computing Basics.pptx
Cloud Computing Basics.pptxCloud Computing Basics.pptx
Cloud Computing Basics.pptxSeethaDinesh
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.pptSeethaDinesh
 
Greedy_Backtracking graph coloring.ppt
Greedy_Backtracking graph coloring.pptGreedy_Backtracking graph coloring.ppt
Greedy_Backtracking graph coloring.pptSeethaDinesh
 
Structure and Union.ppt
Structure and Union.pptStructure and Union.ppt
Structure and Union.pptSeethaDinesh
 
Shortest Path Problem.docx
Shortest Path Problem.docxShortest Path Problem.docx
Shortest Path Problem.docxSeethaDinesh
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptSeethaDinesh
 
NME WPI UNIt 3.pptx
NME WPI UNIt 3.pptxNME WPI UNIt 3.pptx
NME WPI UNIt 3.pptxSeethaDinesh
 
NME UNIT I & II MATERIAL.pdf
NME UNIT I & II MATERIAL.pdfNME UNIT I & II MATERIAL.pdf
NME UNIT I & II MATERIAL.pdfSeethaDinesh
 

More from SeethaDinesh (20)

Input Devices.pptx
Input Devices.pptxInput Devices.pptx
Input Devices.pptx
 
Generations of Computers.ppt
Generations of Computers.pptGenerations of Computers.ppt
Generations of Computers.ppt
 
Inheritance in java.ppt
Inheritance in java.pptInheritance in java.ppt
Inheritance in java.ppt
 
Arrays in JAVA.ppt
Arrays in JAVA.pptArrays in JAVA.ppt
Arrays in JAVA.ppt
 
PROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptxPROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptx
 
Cloud Computing Basics.pptx
Cloud Computing Basics.pptxCloud Computing Basics.pptx
Cloud Computing Basics.pptx
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
Greedy_Backtracking graph coloring.ppt
Greedy_Backtracking graph coloring.pptGreedy_Backtracking graph coloring.ppt
Greedy_Backtracking graph coloring.ppt
 
Structure and Union.ppt
Structure and Union.pptStructure and Union.ppt
Structure and Union.ppt
 
Shortest Path Problem.docx
Shortest Path Problem.docxShortest Path Problem.docx
Shortest Path Problem.docx
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
NME UNIT II.ppt
NME UNIT II.pptNME UNIT II.ppt
NME UNIT II.ppt
 
DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
DW unit 3.pptx
DW unit 3.pptxDW unit 3.pptx
DW unit 3.pptx
 
DW unit 2.pdf
DW unit 2.pdfDW unit 2.pdf
DW unit 2.pdf
 
DW Unit 1.pdf
DW Unit 1.pdfDW Unit 1.pdf
DW Unit 1.pdf
 
NME WPI UNIt 3.pptx
NME WPI UNIt 3.pptxNME WPI UNIt 3.pptx
NME WPI UNIt 3.pptx
 
NME UNIT I & II MATERIAL.pdf
NME UNIT I & II MATERIAL.pdfNME UNIT I & II MATERIAL.pdf
NME UNIT I & II MATERIAL.pdf
 

Recently uploaded

Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 

Recently uploaded (20)

Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 

Binary Tree Traversal and Graph Representations

  • 1. Data Structures and Algorithms Unit - II
  • 2. Unit II Trees – Binary tree representations – Tree Traversal – Threaded Binary Trees – Binary Tree Representation of Trees – Graphs and Representations – Traversals, Connected Components and Spanning Trees – Shortest Paths and Transitive closure – Activity Networks – Topological Sort and Critical Paths.
  • 3. • Atree is an abstract model of ahierarchical structure that consistsof nodes with aparent-child relationship. • Treeis asequence of nodes • There is astarting node known asaroot node • Everynode other than the root hasaparentnode. • Nodes mayhaveany number of children
  • 4.
  • 5.
  • 6. • Root −Node at the top of the treeis called root. • Parent −Any node except root node has one edge upward to a node called parent. • Child − Node below agiven node connected by its edge downward is called its child node. • Sibling – Child of same node are called siblings • Leaf −Node which does not have any child node is called leaf node. • Subtree −Subtree represents descendants of a node. • Levels −Level of anode represents the generation of anode. If root node is at level 0, then itsnext child node is at level 1, its grandchild is at level 2 and soon. • keys−Keyrepresents avalue of anode based on which asearch operation is to be carried out for anode.
  • 7. • Degree of anode: • Thedegree of anode is the number of children of that node • Degree of aTree: • Thedegree of atree is the maximum degree of nodes in agiventree • Path: • It is the sequence of consecutive edges from source node to destination node. • Height of anode: • Theheight of anode is the maxpath length form that node to aleaf node. • Height of atree: • Theheight of atree is the height ofthe root • Depth of atree: • Depth of atree is the maxlevel of any leaf in the tree
  • 8.
  • 9. • Non-linear data structure • Combinesadvantages of an ordered array • Searchingasfast asin ordered array • Insertion and deletion asfast asin linked list • Simple and fast
  • 10. • Directory structure of afile store • Structure of an arithmetic expressions • Used in almost every 3D video game to determine what objects need to be rendered. • Used in almost every high-bandwidth router for storingrouter- tables. • used in compression algorithms, such asthose used by the .jpeg and .mp3 file- formats.
  • 11. • Abinary tree, is atree in which no node canhavemore than two children. • Consider abinary tree T ,here ‘A’is the root node of the binary treeT . • ‘B’ is the left child of ‘A’and ‘C’is theright child of ‘A’ • i.e Ais afather of BandC. • Thenode Band Care called siblings. • Nodes D,H,I,F ,Jare leafnode
  • 12. • Abinary tree, T,is either empty or suchthat III. I. Thasaspecial node called the root node II. Thastwo sets of nodes L Tand RT ,called the left subtree and right subtree of T, respectively. L Tand RTare binarytrees.
  • 13. • Abinary tree is a finite set of elements that are either empty or is partitioned into three disjointsubsets. • Thefirst subset contains asingle element called the root of the tree. • Theother two subsets are themselves binary trees called the left and right sub-trees of the originaltree. • Aleft or right sub-tree canbeempty. • Eachelement of abinary tree is called anode of thetree.
  • 14.
  • 15. • Theroot node of this binary tree isA. • Theleft sub tree of the root node, which we denoted by LA,is theset LA ={B,D,E,G}and the right sub tree of the root node, RAis the set RA={C,F ,H} • Theroot node of LAis node B,the root node of RAis Cand soon
  • 16. • Complete binary tree • Strictly binary tree • Almost complete binary tree
  • 17. • If every non-leaf node in abinary tree hasnonempty leftand right sub-trees, then suchatree is called astrictly binarytree. • Or,to put it another way,all of the nodes in astrictly binary tree are of degree zero or two, never degreeone. • Astrictly binary tree with Nleavesalwayscontains 2N– 1 nodes.
  • 18. • Acompletebinarytree is abinarytree in which every level, except possiblythe last, is completely filled, and all nodes are asfar leftaspossible. • Acompletebinarytreeof depth d is called strictly binary tree if all of whose leavesare at level d. • Acomplete binary tree has2d nodes at every depthd and 2d -1 non leaf nodes
  • 19. • Analmost complete binary tree is atree where for aright child, thereis alwaysa left child, but for aleft child there may not be aright child.
  • 20.
  • 21.
  • 22. • Traversalis aprocessto visit all the nodes of atree and mayprinttheir values too. • All nodes are connected via edges(links) we alwaysstart from theroot (head)node. • There are three wayswhich we useto traverse atree • In-orderTraversal • Pre-orderTraversal • Post-orderTraversal • Generally we traverse atree to search or locate given item or keyin the tree or to print all the values it contains.
  • 24. • Thepreorder traversal of anonempty binary tree is defined asfollows: • Visit the root node • Traversethe left sub-tree inpreorder • Traversethe right sub-tree inpreorder
  • 25. • Thein-order traversal of anonempty binary tree is defined asfollows: • Traversethe left sub-tree inin-order • Visit the root node • Traversethe right sub-tree ininorder • Thein-order traversal output of the given treeis H D I B E A F C G
  • 26. • Thein-order traversal of anonempty binary tree is defined asfollows: • Traversethe left sub-tree inpost-order • Traversethe right sub-tree inpost-order • Visit the root node • Thein-order traversal output of the given treeis H I D E B F G C A
  • 27. • A binary search tree (BST) is a binary tree that is either empty or in which every node contains a key (value) and satisfies the following conditions: • All keys in the left sub-tree of the root are smaller than the key in the root node • All keysin the right sub-tree of the root are greater than the keyin the root node • Theleft and right sub-trees of the root are again binary search trees
  • 28.
  • 29. • Abinary search tree is basically abinary tree, and therefore it canbe traversed in inorder, preorder andpostorder. • If we traverse abinary search tree in inorder and print the identifiers contained in the nodes of the tree, we get asorted list of identifiers in ascending order.
  • 30. • Following operations canbe done in BST : • Search(k,T):Searchfor keyk in the tree T .If k is found in somenode oftree then return true otherwise returnfalse. • Insert(k,T):Insert anew node with value k in the info field in the tree Tsuch that the property of BSTismaintained. • Delete(k, T):Delete anode with value k in the info field from the tree Tsuch that the property of BSTismaintained. • FindMin(T), FindMax(T): Find minimum and maximum element from the given nonempty BST .
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Graph is a non Linear Data structure which is a collection of two finite sets of V & E Where V is vertices(node) and E is Edges (arcs) i.e. G = (V, E) Where V = {A, B, C, D, E, F} & E = { (A, B}, (A,C), (B,C), (B,D), (C,D), (C,E), (D,E), (D,F), (E,F)} The pair (A,B) defines an edge between A and B. A E.g. B D C E F The number of vertices of graph constitute the order of graph. Hence In given Example the order of graph is Six
  • 36. 1. Adjacent vertices: Two vertices are said to be adjacent if they are connected by an edge. e.g. B & C 2. Adjacent Edges: Two edges are said to be adjacent if they are incident on the common vertex. e.g. CD & CE. 3. Path: A Path is a sequence of distinct vertices in which each vertex is adjacent to next one. e.g. ABCDEF 4. Cycle: A cycle is a path consisting of at least three vertices where last vertex is adjacent to the first vertex. e.g. C D F E C 5. Loop: It is special cycle that start and end with same vertex without visiting any other vertex. 6. Degree of Vertex: The degree of a vertex is the number of lines incident on it e.g. degree of D is 4 7. Out-Degree: The out Degree of directed graph is the number of arcs leaving the vertex. 8. In-Degree: In degree of directed graph is number of arcs entering the vertex. 9. Multiple Edges: The distinct parallel edges that connect the same end point.2