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

PPTX
PPTX
Trees (data structure)
PPT
Binomial Heaps
PPT
Unit 3 Tree chapter 5
PPTX
Tree Traversal
PPTX
Bfs and Dfs
PPTX
Unit 5 internal sorting &amp; files
PPT
Binary search trees
Trees (data structure)
Binomial Heaps
Unit 3 Tree chapter 5
Tree Traversal
Bfs and Dfs
Unit 5 internal sorting &amp; files
Binary search trees

What's hot (20)

PPTX
Binomial Heap
PPTX
Tree(Directed and undirected tree)
PDF
Binary tree
PPT
PPTX
Graph data structure and algorithms
PPTX
Binary Heap Tree, Data Structure
PPT
Spanning trees
PPTX
Link list
PPT
358 33 powerpoint-slides_13-graphs_chapter-13
PPTX
Binary Tree in Data Structure
PDF
Python data handling notes
PDF
Tree Data Structure by Daniyal Khan
PPTX
Doubly linked list (animated)
PPTX
10. Search Tree - Data Structures using C++ by Varsha Patil
PPT
Binary Search Tree
PPT
1.5 binary search tree
PPTX
DFS and BFS
PPT
BINARY TREE REPRESENTATION.ppt
PPT
Best for b trees
PPTX
Binomial Heap
Tree(Directed and undirected tree)
Binary tree
Graph data structure and algorithms
Binary Heap Tree, Data Structure
Spanning trees
Link list
358 33 powerpoint-slides_13-graphs_chapter-13
Binary Tree in Data Structure
Python data handling notes
Tree Data Structure by Daniyal Khan
Doubly linked list (animated)
10. Search Tree - Data Structures using C++ by Varsha Patil
Binary Search Tree
1.5 binary search tree
DFS and BFS
BINARY TREE REPRESENTATION.ppt
Best for b trees
Ad

Viewers also liked (20)

PPTX
12. Heaps - Data Structures using C++ by Varsha Patil
PDF
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
PPTX
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
PPTX
15. STL - Data Structures using C++ by Varsha Patil
PPTX
4. Recursion - Data Structures using C++ by Varsha Patil
PPTX
14. Files - Data Structures using C++ by Varsha Patil
PPTX
Pointers in c++
PPTX
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
PPTX
Lists, queues and stacks
PPTX
Array,lists and hashes in perl
PPTX
Constructors and destructors
DOCX
Advanced data structures using c++ 3
PPTX
Classes and objects1
PPTX
Structured query language functions
PPTX
Structured query language constraints
PPS
PPTX
Stacks in c++
PDF
Working with Cookies in NodeJS
PPTX
Data types in c++
PPT
C++ data types
12. Heaps - Data Structures using C++ by Varsha Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
16. Algo analysis & Design - 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
14. Files - Data Structures using C++ by Varsha Patil
Pointers in c++
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
Lists, queues and stacks
Array,lists and hashes in perl
Constructors and destructors
Advanced data structures using c++ 3
Classes and objects1
Structured query language functions
Structured query language constraints
Stacks in c++
Working with Cookies in NodeJS
Data types in c++
C++ data types
Ad

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

PPTX
7. Tree - Data Structures using C++ by Varsha Patil
PPTX
8. Graph - Data Structures using C++ by Varsha Patil
PPT
chap11.ppt
PPT
btrees.ppt ttttttttttttttttttttttttttttt
PPTX
B trees
PPTX
11. Hashing - Data Structures using C++ by Varsha Patil
PPT
data structure module fourth module linked list
PPTX
3. Stack - Data Structures using C++ by Varsha Patil
PPTX
6. Linked list - Data Structures using C++ by Varsha Patil
PPT
9910559 jjjgjgjfs lke lwmerfml lew we.ppt
PPTX
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
PPTX
Balanced Tree (AVL Tree & Red-Black Tree)
PDF
PPT
Introduction to data structure by anil dutt
PDF
Binary Search Tree (BST) Explained Step-by-Step
PPT
Trees gt(1)
PPTX
Lecture4b dynamic data_structure
PPT
4.2 bst 03
PPTX
Data Structure & Algorithms | Computer Science
PPT
Binary trees
7. Tree - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil
chap11.ppt
btrees.ppt ttttttttttttttttttttttttttttt
B trees
11. Hashing - Data Structures using C++ by Varsha Patil
data structure module fourth module linked list
3. Stack - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
9910559 jjjgjgjfs lke lwmerfml lew we.ppt
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
Balanced Tree (AVL Tree & Red-Black Tree)
Introduction to data structure by anil dutt
Binary Search Tree (BST) Explained Step-by-Step
Trees gt(1)
Lecture4b dynamic data_structure
4.2 bst 03
Data Structure & Algorithms | Computer Science
Binary trees

Recently uploaded (20)

PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
Introduction to machine learning and Linear Models
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PDF
Lecture1 pattern recognition............
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPT
Quality review (1)_presentation of this 21
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
Supervised vs unsupervised machine learning algorithms
Business Acumen Training GuidePresentation.pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
Introduction to machine learning and Linear Models
Clinical guidelines as a resource for EBP(1).pdf
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Lecture1 pattern recognition............
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
1_Introduction to advance data techniques.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
oil_refinery_comprehensive_20250804084928 (1).pptx
IBA_Chapter_11_Slides_Final_Accessible.pptx
Quality review (1)_presentation of this 21
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Galatica Smart Energy Infrastructure Startup Pitch Deck
Acceptance and paychological effects of mandatory extra coach I classes.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Supervised vs unsupervised machine learning algorithms

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