SlideShare a Scribd company logo
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

PDF
Finding Dense Subgraphs
PPTX
Computer graphics - bresenham line drawing algorithm
PDF
PPTX
Dda algorithm
PPTX
Dda line algorithm presentatiion
PPT
Bresenham's line algo.
PPTX
Circle algorithm
PPT
Lab lecture 2 bresenham
Finding Dense Subgraphs
Computer graphics - bresenham line drawing algorithm
Dda algorithm
Dda line algorithm presentatiion
Bresenham's line algo.
Circle algorithm
Lab lecture 2 bresenham

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

PPTX
ICPC 2015, Tsukuba : Unofficial Commentary
PPT
Zvi random-walks-slideshare
PPTX
PVEB Tree.pptx
PDF
Problems in parallel computations of tree functions
PPT
Interpolating evolutionary tracks of rapidly rotating stars - presentation
PDF
Analysis and design of a half hypercube interconnection network topology
PPT
3.8 quick sort
PPTX
Slop Intercept Method
PPTX
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
PDF
DAA Notes.pdf
DOC
algorithm Unit 3
PPT
Lect no 13 ECC.ppt
PPT
Lect no 13 ECC.ppt
PPT
e048b527dca76980222bf258a30545f8_MIT15_082JF10_lec16.ppt
PPTX
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
DOC
Unit 3 daa
PPT
Mid point line algorithm by kohen's sutherland
PPTX
ODP
Machine Learning With Neural Networks
ICPC 2015, Tsukuba : Unofficial Commentary
Zvi random-walks-slideshare
PVEB Tree.pptx
Problems in parallel computations of tree functions
Interpolating evolutionary tracks of rapidly rotating stars - presentation
Analysis and design of a half hypercube interconnection network topology
3.8 quick sort
Slop Intercept Method
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
DAA Notes.pdf
algorithm Unit 3
Lect no 13 ECC.ppt
Lect no 13 ECC.ppt
e048b527dca76980222bf258a30545f8_MIT15_082JF10_lec16.ppt
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
Unit 3 daa
Mid point line algorithm by kohen's sutherland
Machine Learning With Neural Networks
Ad

Recently uploaded (20)

PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
web development for engineering and engineering
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Welding lecture in detail for understanding
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Well-logging-methods_new................
PPTX
additive manufacturing of ss316l using mig welding
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Lecture Notes Electrical Wiring System Components
CYBER-CRIMES AND SECURITY A guide to understanding
UNIT-1 - COAL BASED THERMAL POWER PLANTS
R24 SURVEYING LAB MANUAL for civil enggi
web development for engineering and engineering
Automation-in-Manufacturing-Chapter-Introduction.pdf
UNIT 4 Total Quality Management .pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Welding lecture in detail for understanding
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Construction Project Organization Group 2.pptx
Sustainable Sites - Green Building Construction
Internet of Things (IOT) - A guide to understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Well-logging-methods_new................
additive manufacturing of ss316l using mig welding
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Ad

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.