SlideShare a Scribd company logo
1 of 38
M way Search Tree
M way search Tree
• A tree with maximum of m children is known as M way search Tree.
• M way search tree are generalised versions of binary search trees.
• An m way search tree ,tree may be an empty tree if tree is non empty,
it satisfies the following properties.
• Each nodes has at most m child nodes.
• If a node has k child nodes where k<=m then the node can have only
(k-1) keys k1,k2…..
Ex. Of m way search tree
• 10 60 100 200 40 120 80 90 70 170 180 190
Types of binary trees
• Complete binary trees- a complete binary tree is a type of binary tree
which satisfies to Properties:
• A. First every level in a complete binary tree except the last one must
be completely filled.
• Second, all the notes in the complete binary tree must appear left as
much as possible.
• In a complete binary tree the number of notes at level n is Nodes.
• Also the total number of nodes in a complete binary tree of depth d is
equal to the sum of all nodes present at each level between 0 and d.
Extended binary tree
• Extended binary trees are also known as 2T trees or strict binary tree.
• A binary tree is said to be an extended binary tree if and only if every
node in the tree has either zero children or two children.
• In an extended binary tree nodes having two children were known as
internal nodes. If Strictly binary tree has N leaf nodes then the
number of internal notes will be N-1.
• Notes having no children are known as external nodes.
Perfect binary tree
• A perfect binary tree is a type of binary tree in which every internal
node has exactly two child nodes and all the leaf nodes are the same
level all the internal nodes have a degree of two.
B Tree
• The keys and data can be stored in both the Internal and leaf nodes.
• Leaf node cannot store using link list.
• A B- tree is a self balanced search tree with multiple keys in every
node and more than 2 Children for every node.
• The leaf nodes store pointers rather than actual records.
• These tree waste space.
• Searching becomes difficult in B trees as data cannot be found in leaf
node.
B tree
• All leaf nodes are at the bottom level or at the same level.
• Every node in a B tree can have at most M children.
• The root node can have at least two children if it is not a leaf node
and it can obviously have no children if it is a leaf node.
• Each node in a B tree can have at least m/2 children except the root
node and the leaf node.
• Each leaf node must contain at least ceil (m/2-1) keys.
Ex of B tree
• 30,45,75,10,80,40,90,6,15,22,33,9,5,12,77,43,37,3,11,49
B Trees
• The data and keys can only be stored in the leaf node.
• At the bottom leaf nodes are linked.
• B tree is an n array tree with a variable but often large number of children
per node.A B tree consists of a root, internal nodes and leaf. the root
maybe either a leaf or a node with two or more children.
• The leaf nodes of the tree store actual records rather their pointers.
• The records can be accessed either sequently or randomly.
• These trees do not waste space.
• Searching is easy because all data is found in leaf nodes.
• Similarly deletion is also very simple as it will only take place in the leaf
nodes.
B
Graph
• A graph is a collection of some vertices (nodes) and edges that
connect these vertices.
• A graph G can be defined as an ordered set of vertices and edges
(V,E) ,where V(G) represents the set of vertices and E(G) represents
the set of edges that connect these vertices.V(G) ={A,B,C,D,P,Q}
represents the set of vertices.
• And E(G)={(A,B),(B,D),(D,C),(C,A),(C,Q),(Q,D),(A,P) ,(P,C) } represents
the set of edges.
Definitions
• Degree of vertex/node-The degree of a node is the total number of
edges incident to that particular node. Here the degree of the node B
is 3 ,as three edges are incident of the node B.A vertex of degree one
is called pendant vertex.
• In-degree of a node- The in- degree of a node is equal to the number
of edges arriving at a particular node.
• Out degree of a node-The out degree is equal to the number of edges
leaving that particular node.
• Isolated node/vertex-A node having zero edges is known as the
isolated node. The degree of such a node is zero.
• Pendant node/vertex- A node having one edge is known as pendant
node. The degree of such a node is one.
Loop
• If an edge has a starting and ending point at the same node, that is
e=(A,A) ,then it is known as loop.
• Multi Graph –a graph G(V,E) is known as a multi graph if it contains
either a loop, parallel edges or both.
• Cycle- It is a path containing one or more edges which starts from a
particular node and also terminates at the same node.
• Cyclic graph-A graph which has cycle in it is known as a cyclic graph.
• Acyclic graph- A graph without any cycle is known as an acyclic graph.
Graph Representation
• Sequential representation of graph. Using Adjacency Matrix
• Linked representation of graph using Adjacency list
• Adjacency matrix representation- An adjacency matrix is used to
represent the information of the nodes which are adjacent to one
another.The two nodes will only be adjacent when there is an edge
connecting those nodes.
• An adjacency matrix representation of a graph cannot contain
information of parallel edges.
Adjacency list representation
• The adjacency matrix representation has some major drawbacks. First
,it was very difficult to insert and delete the nodes in/from the graph
as the size of the matrix needs to be changed accordingly, which is a
very time consuming process.
• In Adjacency list representation , every node is linked to its list of all
the other nodes which are adjacent to it.Adjacency list representation
makes it easier to add or delete nodes.
Graph traversal Techniques
• Breadth First Search(BFS)
• Depth First Search(DFS)
• Breadth first search is a traversal technique that uses the queue as an
auxiliary data structure for traversing all member nodes of a graph.
• In this technique ,first we will select any node in the graph as a starting
node, and then we will take all the nodes adjacent to the starting node.
• FIFO(queue)
• Work on shallowest nodes
• Complete
• Time complexity O(V+E)
Ex of BFS
Depth First Search
• Depth first search is another traversal technique that the stack as an
auxiliary data structure for traversing all the member nodes of a graph.
• In this technique , we first select any node in the graph as a starting node,
and then we travel along a path which begins from the starting node.
• We will visit the adjacent node of the starting node, and again the adjacent
node of the previous node, and so on.
• LIFO(stack)
• Work on deepest node
• Incomplete
• Time complexity O(V+E)
DFS
Hashing
• Hashing is the process of mapping keys to their appropriate locations in the hash table. It
is the most effective technique of searching the values in an array or in a hash table.
• Hash Table:
• A Hash table is a data structure which supports one of the efficient searching techniques,
that is Hashing.
• A hash table is an array in which the data is accessed through a special index called a key.
• In a hash table, keys are mapped to the Array positions by a hash function.
• A hash function is a function, or we can say that it is a mathematical formula, which
when applied to a key, produces an integer which is used as an index to find a key in the
hash table.
• Thus, a value stored Ina hash table can be searched in O(1) time with the help of a hash
function.
Hash functions
• A hash function is a mathematical formula which when applied to a
key ,Produces an integer which is used as an index to find a key in the
hash table.
• Characteristics of the hash function
• There are four main characteristics of hash functions which are:
• The hash function uses all the input data.
• The hash function must generate different hash values.
• The hash value is fully determined by the data being hashed.
• The hash function must distribute the keys uniformly across the entire
hash table.
Different types of hash functions
• Division method-
• In the division method, a key K is mapped into one of the m slots by
taking the remainder of k divided by m. In simple terms, we can say
that this method divides an integer,say x by m and then uses the
reminders so obtained. It is the simplest method of hashing.The hash
function is given by:
• h(k)=k mod m
• h(k) Address
• K key
• m no. Of slots
Mid Square method
• In the mid square method, we will calculate the square of the given
key. After getting the number, we will extract some digits from the
middle of that number as an address.
• For example , if key k=5025
• Then k. =25250625
• Thus h(5025)=50
Folding method
• In the folding method, we will break the key into pieces such that
each piece has the same number of digits except the last one, which
may have fewer digits as compare to other pieces. Now, these
individual pieces are added. We will ignore the carry if it exists.
Hence, the hash value is formed.
• For example: if m=100 and the key k=12345678, then the indices will
vary from 0 to 99 and thus, each piece of the key must have two
digits. Therefore, the given key will be broken into four pieces, that is
12,34,56 and 78.Now we will add all these ,that is 12+34+56+78=180
• Thus, the hash value will be 80 (ignore the last carry)
Load factor
• Load factor is defined as m/n where n is the total size of the hash
table and m is the preferred number of entries which can be inserted
before a increment in size of the underlying data structure is required.
B tree ,B plus and graph

More Related Content

Similar to B tree ,B plus and graph

Similar to B tree ,B plus and graph (20)

Graph & Heap in Data Structure (Basic Information)
Graph & Heap in Data Structure (Basic Information)Graph & Heap in Data Structure (Basic Information)
Graph & Heap in Data Structure (Basic Information)
 
Data Structures 5
Data Structures 5Data Structures 5
Data Structures 5
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Tree 11.ppt
Tree 11.pptTree 11.ppt
Tree 11.ppt
 
Depth first traversal(data structure algorithms)
Depth first traversal(data structure algorithms)Depth first traversal(data structure algorithms)
Depth first traversal(data structure algorithms)
 
Multiway Trees.ppt
Multiway Trees.pptMultiway Trees.ppt
Multiway Trees.ppt
 
ppt 1.pptx
ppt 1.pptxppt 1.pptx
ppt 1.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
 
DSA-Unit-2.pptx
DSA-Unit-2.pptxDSA-Unit-2.pptx
DSA-Unit-2.pptx
 
Hashing
HashingHashing
Hashing
 
Tree
TreeTree
Tree
 
Tree
TreeTree
Tree
 
Tree
TreeTree
Tree
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
B-and-B-Tree-ppt presentation in data structure
B-and-B-Tree-ppt presentation in data structureB-and-B-Tree-ppt presentation in data structure
B-and-B-Tree-ppt presentation in data structure
 
ds bridge.pptx
ds bridge.pptxds bridge.pptx
ds bridge.pptx
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
 
Data structure(Part 2)
Data structure(Part 2)Data structure(Part 2)
Data structure(Part 2)
 
Trees
TreesTrees
Trees
 
Data Structures 4
Data Structures 4Data Structures 4
Data Structures 4
 

More from RaaviKapoor

CENSORSHIP OF MEDIA : PROS & CONS
CENSORSHIP OF MEDIA : PROS & CONSCENSORSHIP OF MEDIA : PROS & CONS
CENSORSHIP OF MEDIA : PROS & CONSRaaviKapoor
 
PARTIES AND THE PARTY SYSTEM IN INDIA
PARTIES AND THE PARTY SYSTEM IN INDIAPARTIES AND THE PARTY SYSTEM IN INDIA
PARTIES AND THE PARTY SYSTEM IN INDIARaaviKapoor
 
Era of one party dominance
Era of one party dominanceEra of one party dominance
Era of one party dominanceRaaviKapoor
 
Politics of planned development
Politics of planned developmentPolitics of planned development
Politics of planned developmentRaaviKapoor
 
Plant Presentation
Plant PresentationPlant Presentation
Plant PresentationRaaviKapoor
 
Binary Search Tree.pptx
Binary Search Tree.pptxBinary Search Tree.pptx
Binary Search Tree.pptxRaaviKapoor
 
Instruction Formats
Instruction FormatsInstruction Formats
Instruction FormatsRaaviKapoor
 

More from RaaviKapoor (10)

CENSORSHIP OF MEDIA : PROS & CONS
CENSORSHIP OF MEDIA : PROS & CONSCENSORSHIP OF MEDIA : PROS & CONS
CENSORSHIP OF MEDIA : PROS & CONS
 
PARTIES AND THE PARTY SYSTEM IN INDIA
PARTIES AND THE PARTY SYSTEM IN INDIAPARTIES AND THE PARTY SYSTEM IN INDIA
PARTIES AND THE PARTY SYSTEM IN INDIA
 
Era of one party dominance
Era of one party dominanceEra of one party dominance
Era of one party dominance
 
Politics of planned development
Politics of planned developmentPolitics of planned development
Politics of planned development
 
Plant Presentation
Plant PresentationPlant Presentation
Plant Presentation
 
Linked List
Linked ListLinked List
Linked List
 
Binary Search Tree.pptx
Binary Search Tree.pptxBinary Search Tree.pptx
Binary Search Tree.pptx
 
Acid Rain
Acid RainAcid Rain
Acid Rain
 
Instruction Formats
Instruction FormatsInstruction Formats
Instruction Formats
 
IT.pptx
IT.pptxIT.pptx
IT.pptx
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 

B tree ,B plus and graph

  • 2. M way search Tree • A tree with maximum of m children is known as M way search Tree. • M way search tree are generalised versions of binary search trees. • An m way search tree ,tree may be an empty tree if tree is non empty, it satisfies the following properties. • Each nodes has at most m child nodes. • If a node has k child nodes where k<=m then the node can have only (k-1) keys k1,k2…..
  • 3. Ex. Of m way search tree • 10 60 100 200 40 120 80 90 70 170 180 190
  • 4. Types of binary trees • Complete binary trees- a complete binary tree is a type of binary tree which satisfies to Properties: • A. First every level in a complete binary tree except the last one must be completely filled. • Second, all the notes in the complete binary tree must appear left as much as possible. • In a complete binary tree the number of notes at level n is Nodes. • Also the total number of nodes in a complete binary tree of depth d is equal to the sum of all nodes present at each level between 0 and d.
  • 5.
  • 6. Extended binary tree • Extended binary trees are also known as 2T trees or strict binary tree. • A binary tree is said to be an extended binary tree if and only if every node in the tree has either zero children or two children. • In an extended binary tree nodes having two children were known as internal nodes. If Strictly binary tree has N leaf nodes then the number of internal notes will be N-1. • Notes having no children are known as external nodes.
  • 7. Perfect binary tree • A perfect binary tree is a type of binary tree in which every internal node has exactly two child nodes and all the leaf nodes are the same level all the internal nodes have a degree of two.
  • 8. B Tree • The keys and data can be stored in both the Internal and leaf nodes. • Leaf node cannot store using link list. • A B- tree is a self balanced search tree with multiple keys in every node and more than 2 Children for every node. • The leaf nodes store pointers rather than actual records. • These tree waste space. • Searching becomes difficult in B trees as data cannot be found in leaf node.
  • 9. B tree • All leaf nodes are at the bottom level or at the same level. • Every node in a B tree can have at most M children. • The root node can have at least two children if it is not a leaf node and it can obviously have no children if it is a leaf node. • Each node in a B tree can have at least m/2 children except the root node and the leaf node. • Each leaf node must contain at least ceil (m/2-1) keys.
  • 10. Ex of B tree • 30,45,75,10,80,40,90,6,15,22,33,9,5,12,77,43,37,3,11,49
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. B Trees • The data and keys can only be stored in the leaf node. • At the bottom leaf nodes are linked. • B tree is an n array tree with a variable but often large number of children per node.A B tree consists of a root, internal nodes and leaf. the root maybe either a leaf or a node with two or more children. • The leaf nodes of the tree store actual records rather their pointers. • The records can be accessed either sequently or randomly. • These trees do not waste space. • Searching is easy because all data is found in leaf nodes. • Similarly deletion is also very simple as it will only take place in the leaf nodes.
  • 16. B
  • 17. Graph • A graph is a collection of some vertices (nodes) and edges that connect these vertices.
  • 18. • A graph G can be defined as an ordered set of vertices and edges (V,E) ,where V(G) represents the set of vertices and E(G) represents the set of edges that connect these vertices.V(G) ={A,B,C,D,P,Q} represents the set of vertices. • And E(G)={(A,B),(B,D),(D,C),(C,A),(C,Q),(Q,D),(A,P) ,(P,C) } represents the set of edges.
  • 19. Definitions • Degree of vertex/node-The degree of a node is the total number of edges incident to that particular node. Here the degree of the node B is 3 ,as three edges are incident of the node B.A vertex of degree one is called pendant vertex.
  • 20. • In-degree of a node- The in- degree of a node is equal to the number of edges arriving at a particular node. • Out degree of a node-The out degree is equal to the number of edges leaving that particular node. • Isolated node/vertex-A node having zero edges is known as the isolated node. The degree of such a node is zero.
  • 21. • Pendant node/vertex- A node having one edge is known as pendant node. The degree of such a node is one.
  • 22. Loop • If an edge has a starting and ending point at the same node, that is e=(A,A) ,then it is known as loop.
  • 23. • Multi Graph –a graph G(V,E) is known as a multi graph if it contains either a loop, parallel edges or both. • Cycle- It is a path containing one or more edges which starts from a particular node and also terminates at the same node. • Cyclic graph-A graph which has cycle in it is known as a cyclic graph. • Acyclic graph- A graph without any cycle is known as an acyclic graph.
  • 24. Graph Representation • Sequential representation of graph. Using Adjacency Matrix • Linked representation of graph using Adjacency list • Adjacency matrix representation- An adjacency matrix is used to represent the information of the nodes which are adjacent to one another.The two nodes will only be adjacent when there is an edge connecting those nodes. • An adjacency matrix representation of a graph cannot contain information of parallel edges.
  • 25. Adjacency list representation • The adjacency matrix representation has some major drawbacks. First ,it was very difficult to insert and delete the nodes in/from the graph as the size of the matrix needs to be changed accordingly, which is a very time consuming process. • In Adjacency list representation , every node is linked to its list of all the other nodes which are adjacent to it.Adjacency list representation makes it easier to add or delete nodes.
  • 26. Graph traversal Techniques • Breadth First Search(BFS) • Depth First Search(DFS) • Breadth first search is a traversal technique that uses the queue as an auxiliary data structure for traversing all member nodes of a graph. • In this technique ,first we will select any node in the graph as a starting node, and then we will take all the nodes adjacent to the starting node. • FIFO(queue) • Work on shallowest nodes • Complete • Time complexity O(V+E)
  • 28. Depth First Search • Depth first search is another traversal technique that the stack as an auxiliary data structure for traversing all the member nodes of a graph. • In this technique , we first select any node in the graph as a starting node, and then we travel along a path which begins from the starting node. • We will visit the adjacent node of the starting node, and again the adjacent node of the previous node, and so on. • LIFO(stack) • Work on deepest node • Incomplete • Time complexity O(V+E)
  • 29. DFS
  • 30.
  • 31.
  • 32. Hashing • Hashing is the process of mapping keys to their appropriate locations in the hash table. It is the most effective technique of searching the values in an array or in a hash table. • Hash Table: • A Hash table is a data structure which supports one of the efficient searching techniques, that is Hashing. • A hash table is an array in which the data is accessed through a special index called a key. • In a hash table, keys are mapped to the Array positions by a hash function. • A hash function is a function, or we can say that it is a mathematical formula, which when applied to a key, produces an integer which is used as an index to find a key in the hash table. • Thus, a value stored Ina hash table can be searched in O(1) time with the help of a hash function.
  • 33. Hash functions • A hash function is a mathematical formula which when applied to a key ,Produces an integer which is used as an index to find a key in the hash table. • Characteristics of the hash function • There are four main characteristics of hash functions which are: • The hash function uses all the input data. • The hash function must generate different hash values. • The hash value is fully determined by the data being hashed. • The hash function must distribute the keys uniformly across the entire hash table.
  • 34. Different types of hash functions • Division method- • In the division method, a key K is mapped into one of the m slots by taking the remainder of k divided by m. In simple terms, we can say that this method divides an integer,say x by m and then uses the reminders so obtained. It is the simplest method of hashing.The hash function is given by: • h(k)=k mod m • h(k) Address • K key • m no. Of slots
  • 35. Mid Square method • In the mid square method, we will calculate the square of the given key. After getting the number, we will extract some digits from the middle of that number as an address. • For example , if key k=5025 • Then k. =25250625 • Thus h(5025)=50
  • 36. Folding method • In the folding method, we will break the key into pieces such that each piece has the same number of digits except the last one, which may have fewer digits as compare to other pieces. Now, these individual pieces are added. We will ignore the carry if it exists. Hence, the hash value is formed. • For example: if m=100 and the key k=12345678, then the indices will vary from 0 to 99 and thus, each piece of the key must have two digits. Therefore, the given key will be broken into four pieces, that is 12,34,56 and 78.Now we will add all these ,that is 12+34+56+78=180 • Thus, the hash value will be 80 (ignore the last carry)
  • 37. Load factor • Load factor is defined as m/n where n is the total size of the hash table and m is the preferred number of entries which can be inserted before a increment in size of the underlying data structure is required.