SlideShare a Scribd company logo
1 of 23
Download to read offline
B -Tree, Hamiltonian cycle & Eulerian path
IIIT Allahabad
Sanjay kumar
MBI2020015
Motivation For B tree
● So far we have assume that we can store an entire data structure in
main memory
● What if we have so much data that it won’t fit?
● We will have to use disk storage but when this happens our time
complexity fails
● The problem is that Big-Oh analysis assumes that all operations take
roughly equal time
● This is not the case when disk access is involved
Motivation Cont..
● Assume that a disk spins at 3600 RPM
● In 1 minute it makes 3600 revolutions, hence one revolution occurs in 1/60 of
a second
● Assume that we use an AVL tree to store all the covid’19 patient details in
india (about 20 lakh records)
● We know we can’t improve on the log n for a binary tree
● But, the solution is to use more branches and thus less height, as branching
increases, depth decreases
What is B - Tree and Properties?
● A B -tree of order m is an m-way tree where each node may have up to m
children
● Root :
- It can have 2 children or ‘m’ children, where ‘m’ is called order of the tree
● Internal nodes :
- Internal node can store upto ‘m-1’ keys
- They can have between ⎡m / 2⎤ and ‘m’ children
<Ptr < K1, Pr1 > Ptr<K2, Pr2>- - - - - - -<Kq-1, Pr-1>Pq>
Properties:
● Leaf:
- A leaf may store between ⎡(m -1)/ 2⎤ and m-1 keys
- All leaves are at the same depth
Example of B -Tree
The height of a B -tree
● If n =>1,then for any n -key B-tree of height h and minimum degree t =>2
h <= log t (n+1)/2.
Insertion into B - tree
Insertion Algorithm
● Insertion: when a node becomes too full, split it into two nodes and promote
the middle key into a parent key. Repeat recursively on the parent key
● Num of node after adding the key:
Fewer than ‘m’ - 1
Equal to ‘m’ Overflow
Deletion
If P is Tp then (p-1)KE
For min ceil[p/2-1] KE
Underflow : Tp = KE
Time complexity
● Search (logn)
● Insert (logn)
● Delete (logn)
Why we use B -tree
● When searching tables held on disc, the cost of each disc transfer is high but
doesn't depend much on the amount of data transferred, especially if
consecutive items are transferred
-If we use a B-tree of order 101, say, we can transfer each node in one disc
read operation
Cont...
● If we take m = 3, we get a 2-3 tree, in which non-leaf nodes have two or
three children (i.e., one or two keys)
– B-Trees are always balanced (since the leaves are all at the same
level), so 2-3 trees make a good type of balanced tree
Hamiltonian Cycle
In the mathematical field of graph theory, a Hamiltonian cycle (or traceable path) is
a path in which an undirected or directed graph that visits each vertex exactly
once.
A Hamiltonian cycle in a
dodecahedron
The figure has 20 red dots. Can you draw a path that visits each vertex (Dots)
exactly once?
Solution:
Icosian game developed by William Rowan Hamilton
Hamiltonian path problem
Knight Tours Revisited
● Let us form a graph G = (V, E) as follows:
● V = the squares of a chessboard
● E = the set of edges (v, w) where v and w are squares
on the chessboard and a knight can jump from v to w in
a single move.
● Hence, a knight tour is just a Hamiltonian Cycle in this graph
Theorem and Application of Hamiltonian cycle
Theorem: The Hamiltonian Cycle Problem is NP-Complete
● This result explains why knight tours were so difficult to find, there is no
known quick method to find them
Application of Hamiltonian cycle:
● Computer graphics
● Mapping genomes
● Operation research
Eulerian Path
● An Euler path is a path in a graph that uses every edge of a graph exactly
once
● An Euler path starts and ends at different vertices
How to find given graph is eulerian or not?
● Given a drawing on a piece of paper, try to cross all the lines with a pen such
that the pen doesn’t leave the paper and you mustn’t cross a line more than
once.
● An undirected graph has Eulerian Path if following two conditions are true:
-All vertices with non-zero degree are connected. We don’t care about
vertices with zero degree because they don’t belong to Eulerian Path
-If a graph has Eulerian path then no. of odd degree vertices is either ‘0’ or
‘2’(start !=end)
Fleury’s algorithm for printing eulerian path or circuit
Step 1: Make Sure the graph has either ‘0’ or ‘2’ odd vertices
Step 2: If there are ‘0’ odd vertices start anywhere. If there are ‘2’ odd vertices
start at one of them
Step 3: fallow edges one at a time. If you have bridge and a non bridge always
choose non bridge
Step 4: Stop when run out of the edges
Example:
1. We pick ‘2-0’. We remove this
edge and move to vertex ‘0’
2. Euler tour ‘2-0’
3. Euler tour ‘2-0 0-1’
4. Euler tour ‘2-0 0-1 1-2’
5. Euler tour ‘2-0 0-1 1-2 2-3’
Application of Eulerian graph
● 1735, Seven bridge of Königsber
Here eulerian rule is violets so problem in impossible to solve
● DNA fragment assembly
Hybrid approach on the basis of overlap-layout-consensus technique implicitly
solves the Hamiltonian path problem and has a high rate of misassembly
Fragment assembly without repeat masking can be done in linear time with
greater accuracy.
.
Thank you sir!

More Related Content

Similar to B tree, Hamiltonian & Eulerian path presentation

Similar to B tree, Hamiltonian & Eulerian path presentation (20)

ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentary
 
Zvi random-walks-slideshare
Zvi random-walks-slideshareZvi random-walks-slideshare
Zvi random-walks-slideshare
 
PVEB Tree.pptx
PVEB Tree.pptxPVEB Tree.pptx
PVEB Tree.pptx
 
Problems in parallel computations of tree functions
Problems in parallel computations of tree functionsProblems in parallel computations of tree functions
Problems in parallel computations of tree functions
 
Interpolating evolutionary tracks of rapidly rotating stars - presentation
Interpolating evolutionary tracks of rapidly rotating stars - presentationInterpolating evolutionary tracks of rapidly rotating stars - presentation
Interpolating evolutionary tracks of rapidly rotating stars - presentation
 
Analysis and design of a half hypercube interconnection network topology
Analysis and design of a half hypercube interconnection network topologyAnalysis and design of a half hypercube interconnection network topology
Analysis and design of a half hypercube interconnection network topology
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
Slop Intercept Method
Slop Intercept MethodSlop Intercept Method
Slop Intercept Method
 
DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
 
Lect no 13 ECC.ppt
Lect no 13 ECC.pptLect no 13 ECC.ppt
Lect no 13 ECC.ppt
 
Lect no 13 ECC.ppt
Lect no 13 ECC.pptLect no 13 ECC.ppt
Lect no 13 ECC.ppt
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Qa 2
Qa 2Qa 2
Qa 2
 
Machine Learning With Neural Networks
Machine Learning  With Neural NetworksMachine Learning  With Neural Networks
Machine Learning With Neural Networks
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
 
Algorithms of graph
Algorithms of graphAlgorithms of graph
Algorithms of graph
 
1579 parametric equations
1579 parametric equations1579 parametric equations
1579 parametric equations
 
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekAIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
 

Recently uploaded

Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 

B tree, Hamiltonian & Eulerian path presentation

  • 1. B -Tree, Hamiltonian cycle & Eulerian path IIIT Allahabad Sanjay kumar MBI2020015
  • 2. Motivation For B tree ● So far we have assume that we can store an entire data structure in main memory ● What if we have so much data that it won’t fit? ● We will have to use disk storage but when this happens our time complexity fails ● The problem is that Big-Oh analysis assumes that all operations take roughly equal time ● This is not the case when disk access is involved
  • 3. Motivation Cont.. ● Assume that a disk spins at 3600 RPM ● In 1 minute it makes 3600 revolutions, hence one revolution occurs in 1/60 of a second ● Assume that we use an AVL tree to store all the covid’19 patient details in india (about 20 lakh records) ● We know we can’t improve on the log n for a binary tree ● But, the solution is to use more branches and thus less height, as branching increases, depth decreases
  • 4. What is B - Tree and Properties? ● A B -tree of order m is an m-way tree where each node may have up to m children ● Root : - It can have 2 children or ‘m’ children, where ‘m’ is called order of the tree ● Internal nodes : - Internal node can store upto ‘m-1’ keys - They can have between ⎡m / 2⎤ and ‘m’ children <Ptr < K1, Pr1 > Ptr<K2, Pr2>- - - - - - -<Kq-1, Pr-1>Pq>
  • 5. Properties: ● Leaf: - A leaf may store between ⎡(m -1)/ 2⎤ and m-1 keys - All leaves are at the same depth
  • 6. Example of B -Tree
  • 7. The height of a B -tree ● If n =>1,then for any n -key B-tree of height h and minimum degree t =>2 h <= log t (n+1)/2.
  • 9. Insertion Algorithm ● Insertion: when a node becomes too full, split it into two nodes and promote the middle key into a parent key. Repeat recursively on the parent key ● Num of node after adding the key: Fewer than ‘m’ - 1 Equal to ‘m’ Overflow
  • 10. Deletion If P is Tp then (p-1)KE For min ceil[p/2-1] KE Underflow : Tp = KE
  • 11. Time complexity ● Search (logn) ● Insert (logn) ● Delete (logn) Why we use B -tree ● When searching tables held on disc, the cost of each disc transfer is high but doesn't depend much on the amount of data transferred, especially if consecutive items are transferred -If we use a B-tree of order 101, say, we can transfer each node in one disc read operation
  • 12. Cont... ● If we take m = 3, we get a 2-3 tree, in which non-leaf nodes have two or three children (i.e., one or two keys) – B-Trees are always balanced (since the leaves are all at the same level), so 2-3 trees make a good type of balanced tree
  • 13. Hamiltonian Cycle In the mathematical field of graph theory, a Hamiltonian cycle (or traceable path) is a path in which an undirected or directed graph that visits each vertex exactly once. A Hamiltonian cycle in a dodecahedron
  • 14. The figure has 20 red dots. Can you draw a path that visits each vertex (Dots) exactly once? Solution: Icosian game developed by William Rowan Hamilton
  • 15. Hamiltonian path problem Knight Tours Revisited ● Let us form a graph G = (V, E) as follows: ● V = the squares of a chessboard ● E = the set of edges (v, w) where v and w are squares on the chessboard and a knight can jump from v to w in a single move. ● Hence, a knight tour is just a Hamiltonian Cycle in this graph
  • 16. Theorem and Application of Hamiltonian cycle Theorem: The Hamiltonian Cycle Problem is NP-Complete ● This result explains why knight tours were so difficult to find, there is no known quick method to find them Application of Hamiltonian cycle: ● Computer graphics ● Mapping genomes ● Operation research
  • 17. Eulerian Path ● An Euler path is a path in a graph that uses every edge of a graph exactly once ● An Euler path starts and ends at different vertices
  • 18. How to find given graph is eulerian or not? ● Given a drawing on a piece of paper, try to cross all the lines with a pen such that the pen doesn’t leave the paper and you mustn’t cross a line more than once. ● An undirected graph has Eulerian Path if following two conditions are true: -All vertices with non-zero degree are connected. We don’t care about vertices with zero degree because they don’t belong to Eulerian Path -If a graph has Eulerian path then no. of odd degree vertices is either ‘0’ or ‘2’(start !=end)
  • 19. Fleury’s algorithm for printing eulerian path or circuit Step 1: Make Sure the graph has either ‘0’ or ‘2’ odd vertices Step 2: If there are ‘0’ odd vertices start anywhere. If there are ‘2’ odd vertices start at one of them Step 3: fallow edges one at a time. If you have bridge and a non bridge always choose non bridge Step 4: Stop when run out of the edges
  • 20. Example: 1. We pick ‘2-0’. We remove this edge and move to vertex ‘0’ 2. Euler tour ‘2-0’ 3. Euler tour ‘2-0 0-1’ 4. Euler tour ‘2-0 0-1 1-2’ 5. Euler tour ‘2-0 0-1 1-2 2-3’
  • 21. Application of Eulerian graph ● 1735, Seven bridge of Königsber Here eulerian rule is violets so problem in impossible to solve ● DNA fragment assembly Hybrid approach on the basis of overlap-layout-consensus technique implicitly solves the Hamiltonian path problem and has a high rate of misassembly
  • 22. Fragment assembly without repeat masking can be done in linear time with greater accuracy.