SlideShare a Scribd company logo
1 of 35
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
1
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
2
 Indexing techniques
 B-trees which prove invaluable for problems of external
information retrieval
 A class of trees called tries, which share some properties
of table lookup
 Important uses of trees in many search techniques
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
3
 A file is a collection of records, each record having one or
more fields
 The fields used to distinguish among the records are
known as keys
 File organization describes the way where the records are
stored in a file
 File organization is concerned with representing data
records on an external storage media
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
4
 The file organization breaks down into two more aspects:
 Directory—for collection of indices
 File organization—for the physical organization of
records
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
5
 File organization is the way records are organized on a
physical storage
 One of such organizations is sequential (ordered and
unordered)
 In this general framework, processing a query or updating
a request would proceed in two steps:
 The indices would be interrogated to determine the
parts of the physical file to be searched
 These parts of the physical file will be searched
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
6
 An index, whether it is a book or a data file index (in
computer memory), is based on the basic concepts such as
keys and reference fields
 The index to a book provides a way to find a topic quickly
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
7
 An index, whether it is a book or a data file index (in
computer memory), is based on the basic concepts such as
keys and reference fields
 The index to a book provides a way to find a topic quickly
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
8
 This is the simplest type of index organization. It is useful
only for the primary key index of a sequentially ordered
file
 In a sequentially ordered file, the physical sequence of
records is ordered by the key, called the primary key
 The cylinder-surface index consists of a cylinder index
and several surface indexes
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
9
For each cylinder, there is a surface index. If the disk has S
usable surfaces, then each surface index has s entries.
The total number of surface index entries is C.S
Emp. No. Emp. Name Cylinder Surface
1
2
3
4
5
6
7
8
Abolee
Anand
Amit
Amol
Rohit
Santosh
Saurabh
Shila
1
1
1
1
2
2
2
2
1
1
2
2
1
1
2
2
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
10
Let there be two surfaces and two records stored per track.
The file is organized sequentially on the field ‘Emp. name’
The cylinder index is shown in following table
Emp. No. Highest Key Value
1
2
Amol
Shila
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
11
 This method of maintaining a file and index is referred to
as ISAM (indexed sequential access method)
 It is the simplest file organization for single key files but
not useful for multiple key files
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
12
 The operations related to hashed indexes are the same as
those for hash tables
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
13
 A multiway search tree is a tree of order m, where each
node has utmost m children
 Fig. shows way search tree:
d e p v
w x y zrh j k lb c
qia f g m n o s t u
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
14
 A B-tree is a balanced M-way tree. A node of the tree
contains many records or keys of records and pointers to
children
 To reduce disk access, the following points are applicable:
 Height is kept minimum
 All leaves are kept at the same level
 All other than leaves must have at least minimum
number of children
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
15
 Definition:
 A B-tree of order m is an m-way tree with the following
properties:
 The number of keys in each internal node is one less than
the number of its non-empty children, and these keys
partition the keys in the children in the fashion of the
search tree
 All leaves are on the same level
 All internal nodes except the root have utmost m non-empty
children and at least [m/2] non-empty children
 The root is either a leaf node, or it has from two to m
children
 A leaf node contains no more than m − 1 keys
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
16
Ptr1 Key1 Ptr2 Key2 Ptri Keyi …….. Keyn-1 Ptrn
X XX
X<Key1 Keyi-1<X<Keyi X>Keyn-1
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
17
 Search a node
 Insertion of a key into a B-tree
 Deletion from a B-tree
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
18
 B+ trees are internal data structures
 That is, the nodes contain whatever information is
associated with the key as well as the key values
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
19
 The structure of a B+ tree can be understood from the
following points:
 A B+ tree is in the form of a balanced tree where every
path from the root of the tree to a leaf of the tree is of
the same length
 Each non-leaf node (internal node) in the tree has
between [n/2] and n children, where n is fixed
 The pointer (Ptr) can point to either a file record or a
bucket of pointers which each point to a file record
 Searching time is less in B+ trees but has some
problem of wasted space
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
20
 Internal node of a B+ tree with q −1 search values
 Leaf node of a B+ tree with q − 1 search values and q − 1
data pointers
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
21
Ptr1 Key1 Ptr2 Key2 Ptri Keyi …….. Keyn-1 Ptrn
X XX
X<Key1 Keyi-1<X<Keyi X>Keyn-1
Tree Pointer
Tree Pointer
Tree Pointer
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
22
 A dynamic index structure that adjusts gracefully to
inserts and deletes
 A balanced tree
 Leaf pages are not allocated sequentially. They are
linked together through pointers (a doubly linked list)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
23
 One solution is to prune from the tree all the branches
that do not lead to any key
 The resulting tree is called a trie (short for reTRIEvaL and
pronounced ‘try’)
 The number of steps needed to search a trie is
proportional to the number of characters in a key
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
24
 Splay trees are a form of a BST. A splay tree maintains a
balance without any explicit balance condition such as
color
 Instead, ‘splay operations’, which involve rotations, are
performed within the tree every time an access is made
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
25
 If we use a BST or even an AVL tree, then the records of the newly
admitted patient’s records will go to a leaf position, far from the
root, and the access will be slower
 Instead, we want to keep the records that are newly inserted or
frequently accessed very near to the root, while the inactive
records far off, in the leaf positions
 However, we do not want to rebuild the tree into the desired
shape. Instead, we need to make a tree a self-adjusting data
structure that automatically changes its shape to bring the
records closer to the root as they are used frequently, allowing
inactive records to drift slowly down towards the leaves. Such
trees are called as splay trees
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
26
 A red-black tree is a BST with one extra bit of storage per
node: its colour, which can either be red or black
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
27
 Every node is either red or black
 All the external nodes (leaf nodes) are black
 The rank in a tree goes from zero upto the maximum rank which
occurs at the root. The rank of two consecutive nodes differs by
utmost 1. Each leaf node has a rank 0
 If a node is red, then both its children are black. In other words,
consecutive red nodes are disallowed. This means every red
node is followed by a black node; on the other hand, a black
node may be followed by a black or a red node
 This implies that utmost 50% of the nodes on any path from
external node to root are red
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
28
 The number of black nodes on any path from but not
including the node x to leaf is called as black height of the
node x, denoted as bh(x)
 Every simple path from the root to a leaf contains the
same number of black nodes
 In addition, every simple path from a node to a
descendent leaf contains the same number of black nodes
 If a black node has a rank r, then its parent has the rank r
+ 1
 If a red node has a rank r, then its parent will have the
rank r as well
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
29
 A KD-tree is a data structure used in computer science
during orthogonal range searching, for instance, to find
the set of points that fall into a given rectangle
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
30
An AA tree is a balanced BST with the following properties:
 Every node is colored either red or black
 The root is black
 If a node is red, both of its children are black
 Every path from a node to a null reference has the same
number of black nodes
 Left children may not be red
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
31
 They eliminate half the reconstructing cases
 They simplify deletion by removing an annoying case
 If an internal node has only one child, that child must be a
red child
 We can always replace a node with the smallest child in the
right subtree; it will either be a leaf node or have a red child
 AA tree, balanced BST, supports efficient operations, since
most operations only have to traverse one or two root-to-
leaf paths
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
32
 In each node of AA tree, we store a level. The level is
defined by the following rules:
 If a node is a leaf, its level is one
 If a node is red, its level is the level of its parent
 If a node is black, its level is one less than the level of
its parent
 Here, the level is the number of left links to a null
reference
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
33
 A horizontal link is a connection between a node and a
child with equal levels
 The properties of such horizontal links are as follows:
 Horizontal links are right references
 There cannot be two consecutives horizontal links
 Nodes at level two or higher must have two children
 If a node has no right horizontal link, its two children
are at the same level
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
34

 A node of a BST has only one key value entry stored in it. A multiway
tree has many key values stored in each node and thus each node
may have multiple subtrees
 Different indexing techniques are used to search a record in O(1)
time. The index is a pair of key value and address. It is an indirect
addressing that imposes order on a file without rearranging the file
 Indexing techniques are classified as Hashed indexing, Tree
indexing, B-tree, B+ tree, Trie tree
 Splay trees are self-adjusting trees
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
35

More Related Content

What's hot

Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary searchNisha Soms
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm03446940736
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary searchZia Ush Shamszaman
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)Trupti Agrawal
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Array data structure
Array data structureArray data structure
Array data structuremaamir farooq
 
Binary search tree
Binary search treeBinary search tree
Binary search treeKousalya M
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IAlgorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IMohamed Loey
 
Selection sort and insertion sort
Selection sort and insertion sortSelection sort and insertion sort
Selection sort and insertion sortMay Ann Mendoza
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up ParsingGerwin Ocsena
 
Splay Tree Presentation Slides
Splay Tree Presentation SlidesSplay Tree Presentation Slides
Splay Tree Presentation SlidesMuhammad Shahbaz
 

What's hot (20)

Time complexity
Time complexityTime complexity
Time complexity
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Red black tree
Red black treeRed black tree
Red black tree
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Array data structure
Array data structureArray data structure
Array data structure
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IAlgorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms I
 
Selection sort and insertion sort
Selection sort and insertion sortSelection sort and insertion sort
Selection sort and insertion sort
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up Parsing
 
Splay Tree Presentation Slides
Splay Tree Presentation SlidesSplay Tree Presentation Slides
Splay Tree Presentation Slides
 

Viewers also liked

12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patilwidespreadpromotion
 
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacksandreeamolnar
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perlsana mateen
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsVineeta Garg
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3Shaili Choudhary
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1Vineeta Garg
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functionsVineeta Garg
 
Structured query language constraints
Structured query language constraintsStructured query language constraints
Structured query language constraintsVineeta Garg
 
Working with Cookies in NodeJS
Working with Cookies in NodeJSWorking with Cookies in NodeJS
Working with Cookies in NodeJSJay Dihenkar
 
Data Structure
Data StructureData Structure
Data Structuresheraz1
 

Viewers also liked (20)

12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
 
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacks
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
 
Structured query language constraints
Structured query language constraintsStructured query language constraints
Structured query language constraints
 
Pp
PpPp
Pp
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Working with Cookies in NodeJS
Working with Cookies in NodeJSWorking with Cookies in NodeJS
Working with Cookies in NodeJS
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Data Structure
Data StructureData Structure
Data Structure
 

Similar to 13. Indexing MTrees - Data Structures using C++ by Varsha Patil

7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structureMahmoud Alfarra
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like StructuresIntro C# Book
 
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
datastructure-201021140600.pptx
datastructure-201021140600.pptxdatastructure-201021140600.pptx
datastructure-201021140600.pptxZISAN5
 
SIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptxSIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptxsagabo1
 
Indexing and Hashing.ppt
Indexing and Hashing.pptIndexing and Hashing.ppt
Indexing and Hashing.pptvedantihp21
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashingJeet Poria
 
DATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptxDATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptxAryaMNair6
 
indexingstructureforfiles-160728120658.pdf
indexingstructureforfiles-160728120658.pdfindexingstructureforfiles-160728120658.pdf
indexingstructureforfiles-160728120658.pdfFraolUmeta
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for filesZainab Almugbel
 
Dynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ TreesDynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ TreesPooja Dixit
 
Data structure tree - beginner
Data structure tree - beginnerData structure tree - beginner
Data structure tree - beginnerMD. MARUFUZZAMAN .
 

Similar to 13. Indexing MTrees - Data Structures using C++ by Varsha Patil (20)

7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
 
Data Structures
Data StructuresData Structures
Data Structures
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structure
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
 
A41001011
A41001011A41001011
A41001011
 
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
 
datastructure-201021140600.pptx
datastructure-201021140600.pptxdatastructure-201021140600.pptx
datastructure-201021140600.pptx
 
104333 sri vidhya eng notes
104333 sri vidhya eng notes104333 sri vidhya eng notes
104333 sri vidhya eng notes
 
Ch12
Ch12Ch12
Ch12
 
SIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptxSIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptx
 
Indexing and Hashing.ppt
Indexing and Hashing.pptIndexing and Hashing.ppt
Indexing and Hashing.ppt
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashing
 
DATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptxDATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptx
 
indexingstructureforfiles-160728120658.pdf
indexingstructureforfiles-160728120658.pdfindexingstructureforfiles-160728120658.pdf
indexingstructureforfiles-160728120658.pdf
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
 
ch12
ch12ch12
ch12
 
Dynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ TreesDynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ Trees
 
Data structure tree - beginner
Data structure tree - beginnerData structure tree - beginner
Data structure tree - beginner
 
5. indexing
5. indexing5. indexing
5. indexing
 

Recently uploaded

RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING
2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING
2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSINGmarianagonzalez07
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfchwongval
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
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
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
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
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 

Recently uploaded (20)

RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING
2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING
2006_GasProcessing_HB (1).pdf HYDROCARBON PROCESSING
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdf
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
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
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
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
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 

13. Indexing MTrees - Data Structures using C++ by Varsha Patil

  • 1. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 1
  • 2. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 2  Indexing techniques  B-trees which prove invaluable for problems of external information retrieval  A class of trees called tries, which share some properties of table lookup  Important uses of trees in many search techniques
  • 3. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 3  A file is a collection of records, each record having one or more fields  The fields used to distinguish among the records are known as keys  File organization describes the way where the records are stored in a file  File organization is concerned with representing data records on an external storage media
  • 4. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 4  The file organization breaks down into two more aspects:  Directory—for collection of indices  File organization—for the physical organization of records
  • 5. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 5  File organization is the way records are organized on a physical storage  One of such organizations is sequential (ordered and unordered)  In this general framework, processing a query or updating a request would proceed in two steps:  The indices would be interrogated to determine the parts of the physical file to be searched  These parts of the physical file will be searched
  • 6. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 6  An index, whether it is a book or a data file index (in computer memory), is based on the basic concepts such as keys and reference fields  The index to a book provides a way to find a topic quickly
  • 7. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 7  An index, whether it is a book or a data file index (in computer memory), is based on the basic concepts such as keys and reference fields  The index to a book provides a way to find a topic quickly
  • 8. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 8  This is the simplest type of index organization. It is useful only for the primary key index of a sequentially ordered file  In a sequentially ordered file, the physical sequence of records is ordered by the key, called the primary key  The cylinder-surface index consists of a cylinder index and several surface indexes
  • 9. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 9 For each cylinder, there is a surface index. If the disk has S usable surfaces, then each surface index has s entries. The total number of surface index entries is C.S Emp. No. Emp. Name Cylinder Surface 1 2 3 4 5 6 7 8 Abolee Anand Amit Amol Rohit Santosh Saurabh Shila 1 1 1 1 2 2 2 2 1 1 2 2 1 1 2 2
  • 10. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 10 Let there be two surfaces and two records stored per track. The file is organized sequentially on the field ‘Emp. name’ The cylinder index is shown in following table Emp. No. Highest Key Value 1 2 Amol Shila
  • 11. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 11  This method of maintaining a file and index is referred to as ISAM (indexed sequential access method)  It is the simplest file organization for single key files but not useful for multiple key files
  • 12. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 12  The operations related to hashed indexes are the same as those for hash tables
  • 13. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 13  A multiway search tree is a tree of order m, where each node has utmost m children  Fig. shows way search tree: d e p v w x y zrh j k lb c qia f g m n o s t u
  • 14. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 14  A B-tree is a balanced M-way tree. A node of the tree contains many records or keys of records and pointers to children  To reduce disk access, the following points are applicable:  Height is kept minimum  All leaves are kept at the same level  All other than leaves must have at least minimum number of children
  • 15. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 15  Definition:  A B-tree of order m is an m-way tree with the following properties:  The number of keys in each internal node is one less than the number of its non-empty children, and these keys partition the keys in the children in the fashion of the search tree  All leaves are on the same level  All internal nodes except the root have utmost m non-empty children and at least [m/2] non-empty children  The root is either a leaf node, or it has from two to m children  A leaf node contains no more than m − 1 keys
  • 16. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 16 Ptr1 Key1 Ptr2 Key2 Ptri Keyi …….. Keyn-1 Ptrn X XX X<Key1 Keyi-1<X<Keyi X>Keyn-1
  • 17. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 17  Search a node  Insertion of a key into a B-tree  Deletion from a B-tree
  • 18. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 18  B+ trees are internal data structures  That is, the nodes contain whatever information is associated with the key as well as the key values
  • 19. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 19  The structure of a B+ tree can be understood from the following points:  A B+ tree is in the form of a balanced tree where every path from the root of the tree to a leaf of the tree is of the same length  Each non-leaf node (internal node) in the tree has between [n/2] and n children, where n is fixed  The pointer (Ptr) can point to either a file record or a bucket of pointers which each point to a file record  Searching time is less in B+ trees but has some problem of wasted space
  • 20. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 20  Internal node of a B+ tree with q −1 search values  Leaf node of a B+ tree with q − 1 search values and q − 1 data pointers
  • 21. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 21 Ptr1 Key1 Ptr2 Key2 Ptri Keyi …….. Keyn-1 Ptrn X XX X<Key1 Keyi-1<X<Keyi X>Keyn-1 Tree Pointer Tree Pointer Tree Pointer
  • 22. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 22  A dynamic index structure that adjusts gracefully to inserts and deletes  A balanced tree  Leaf pages are not allocated sequentially. They are linked together through pointers (a doubly linked list)
  • 23. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 23  One solution is to prune from the tree all the branches that do not lead to any key  The resulting tree is called a trie (short for reTRIEvaL and pronounced ‘try’)  The number of steps needed to search a trie is proportional to the number of characters in a key
  • 24. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 24  Splay trees are a form of a BST. A splay tree maintains a balance without any explicit balance condition such as color  Instead, ‘splay operations’, which involve rotations, are performed within the tree every time an access is made
  • 25. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 25  If we use a BST or even an AVL tree, then the records of the newly admitted patient’s records will go to a leaf position, far from the root, and the access will be slower  Instead, we want to keep the records that are newly inserted or frequently accessed very near to the root, while the inactive records far off, in the leaf positions  However, we do not want to rebuild the tree into the desired shape. Instead, we need to make a tree a self-adjusting data structure that automatically changes its shape to bring the records closer to the root as they are used frequently, allowing inactive records to drift slowly down towards the leaves. Such trees are called as splay trees
  • 26. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 26  A red-black tree is a BST with one extra bit of storage per node: its colour, which can either be red or black
  • 27. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 27  Every node is either red or black  All the external nodes (leaf nodes) are black  The rank in a tree goes from zero upto the maximum rank which occurs at the root. The rank of two consecutive nodes differs by utmost 1. Each leaf node has a rank 0  If a node is red, then both its children are black. In other words, consecutive red nodes are disallowed. This means every red node is followed by a black node; on the other hand, a black node may be followed by a black or a red node  This implies that utmost 50% of the nodes on any path from external node to root are red
  • 28. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 28  The number of black nodes on any path from but not including the node x to leaf is called as black height of the node x, denoted as bh(x)  Every simple path from the root to a leaf contains the same number of black nodes  In addition, every simple path from a node to a descendent leaf contains the same number of black nodes  If a black node has a rank r, then its parent has the rank r + 1  If a red node has a rank r, then its parent will have the rank r as well
  • 29. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 29  A KD-tree is a data structure used in computer science during orthogonal range searching, for instance, to find the set of points that fall into a given rectangle
  • 30. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 30 An AA tree is a balanced BST with the following properties:  Every node is colored either red or black  The root is black  If a node is red, both of its children are black  Every path from a node to a null reference has the same number of black nodes  Left children may not be red
  • 31. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 31  They eliminate half the reconstructing cases  They simplify deletion by removing an annoying case  If an internal node has only one child, that child must be a red child  We can always replace a node with the smallest child in the right subtree; it will either be a leaf node or have a red child  AA tree, balanced BST, supports efficient operations, since most operations only have to traverse one or two root-to- leaf paths
  • 32. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 32  In each node of AA tree, we store a level. The level is defined by the following rules:  If a node is a leaf, its level is one  If a node is red, its level is the level of its parent  If a node is black, its level is one less than the level of its parent  Here, the level is the number of left links to a null reference
  • 33. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 33  A horizontal link is a connection between a node and a child with equal levels  The properties of such horizontal links are as follows:  Horizontal links are right references  There cannot be two consecutives horizontal links  Nodes at level two or higher must have two children  If a node has no right horizontal link, its two children are at the same level
  • 34. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 34   A node of a BST has only one key value entry stored in it. A multiway tree has many key values stored in each node and thus each node may have multiple subtrees  Different indexing techniques are used to search a record in O(1) time. The index is a pair of key value and address. It is an indirect addressing that imposes order on a file without rearranging the file  Indexing techniques are classified as Hashed indexing, Tree indexing, B-tree, B+ tree, Trie tree  Splay trees are self-adjusting trees
  • 35. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 35