UNIT 3 DSA
UNIT 3 DSA
Linked List
o Linked List can be defined as collection of objects called nodes that
are randomly stored in the memory.
o A node contains two fields i.e. data stored at that particular address
and the pointer which contains the address of the next node in the
memory.
o The last node of the list contains pointer to the null.
One way chain or singly linked list can be traversed only in one direction. In
other words, we can say that each node contains only next pointer, therefore
we can not traverse the list in the reverse direction.
Complexity
Data Time Complexity Space
Structure Compleity
Singly Linked θ(n) θ(n) θ(1) θ(1) O(n) O(n) O(1) O(1) O(n)
List
Linked list is the data structure which can overcome all the limitations of an
array. Using linked list is useful because,
1. It allocates the memory dynamically. All the nodes of linked list are non-
contiguously stored in the memory and linked together with the help of
pointers.
2. Sizing is no longer a problem since we do not need to define its size at the
time of declaration. List grows as per the program's demand and limited to
the available memory space.
Insertion
Deletion
Display
Before we implement actual operations, first we need to set up an empty list. First, perform the
following steps before implementing actual operations.
Step 1 - Include all the header files which are used in the program.
Step 2 - Declare all the user defined functions.
Step 3 - Define a Node structure with two members data and next
Step 4 - Define a Node pointer 'head' and set it to NULL.
Step 5 - Implement the main method by displaying operations menu and make suitable
function calls in the main method to perform user selected operation.
Insertion
In a single linked list, the insertion operation can be performed in three ways. They are as follows...
Step 1 - Create a newNode with given value and newNode → next as NULL.
Step 2 - Check whether list is Empty (head == NULL).
Step 3 - If it is Empty then, set head = newNode.
Step 4 - If it is Not Empty then, define a node pointer temp and initialize with head.
Step 5 - Keep moving the temp to its next node until it reaches to the last node in the list
(until temp → next is equal to NULL).
Step 6 - Set temp → next = newNode.
Deletion
In a single linked list, the deletion operation can be performed in three ways. They are as follows...
Search
Initialize PTR with the address of HEAD. Now the PTR points to the first node of the linked
list.
A while loop is executed which will compare data of every node with item.
If item has been found then control goes to last step.
Algorithm: Search
Go To Step 5
ELSE
[END OF IF]
[END OF LOOP]
Step 5: EXIT
Traversing a singly linked list
Traversing a singly linked list simply means, Accessing or printing the values
(i.e., data items stored inside each node) of a singly linked list exactly once
until the end node is reached and, this accessing and printing is sometimes
called “visiting” the linked list. It’s only because, Let’s suppose you wish to
check the data items (values) stored at the node of a given linked list or you
wish to use the node (i.e, either the value or the address stored inside the
node) as part of some other operation or process then traversing is the best
suited way to do that.
The top most node in the stack always contains null in its address field. Lets
discuss the way in which, each operation is performed in linked list
implementation of stack.
Adding a node to the stack (Push operation)
Adding a node to the stack is referred to as push operation. Pushing an
element to a stack in linked list implementation is different from that of an
array implementation. In order to push an element onto the stack, the
following steps are involved.
In a linked queue, each node of the queue consists of two parts i.e. data part
and the link part. Each element of the queue points to its immediate next
element in the memory.
In the linked queue, there are two pointers maintained in the memory i.e.
front pointer and rear pointer. The front pointer contains the address of the
starting element of the queue while the rear pointer contains the address of
the last element of the queue.
Insertion and deletions are performed at rear and front end respectively. If
front and rear both are NULL, it indicates that the queue is empty.
Insert operation
The insert operation append the queue by adding an element to the end of the queue. The new
element will be the last element of the queue.
Firstly, allocate the memory for the new node ptr by using the following statement.
There can be the two scenario of inserting this new node ptr into the linked queue.
In the first scenario, we insert element into an empty queue. In this case, the condition front =
NULL becomes true. Now, the new element will be added as the only element of the queue and
the next pointer of front and rear pointer both, will point to NULL.
In the second case, the queue contains more than one element. The condition front
= NULL becomes false. In this scenario, we need to update the end pointer rear so
that the next pointer of rear will point to the new node ptr. Since, this is a linked
queue, hence we also need to make the rear pointer point to the newly added
node ptr. We also need to make the next pointer of rear point to NULL.
In this way, the element is inserted into the queue. The algorithm and the C
implementation is given as follows.
Algorithm
o Step 1: Allocate the space for the new node PTR
o Step 2: SET PTR -> DATA = VAL
o Step 3: IF FRONT = NULL
SET FRONT = REAR = PTR
SET FRONT -> NEXT = REAR -> NEXT = NULL
ELSE
SET REAR -> NEXT = PTR
SET REAR = PTR
SET REAR -> NEXT = NULL
[END OF IF]
o Step 4: END
A header node is a special node that is found at the beginning of the list. A list
that contains this type of node, is called the header-linked list. This type of list is
useful when information other than that found in each node is needed.
For example, suppose there is an application in which the number of items in a
list is often calculated. Usually, a list is always traversed to find the length of the
list. However, if the current length is maintained in an additional header node
that information can be easily obtained.
Double linked list is a sequence of elements in which every element has links to its previous
element and next element in the sequence.
In a double linked list, every node has a link to its previous node and next node. So, we can traverse
forward by using the next field and can traverse backward by using the previous field. Every node in
a double linked list contains three fields and they are shown in the following figure...
Here, 'link1' field is used to store the address of the previous node in the sequence, 'link2' field is
used to store the address of the next node in the sequence and 'data' field is used to store the
actual value of that node.
EXAMPLE:-
In double linked list, the first node must be always pointed by head.
1. Insertion
2. Deletion
3. Display
Insertion
In a double linked list, the insertion operation can be performed in three ways as follows...
Step 1 - Create a newNode with given value and newNode → previous as NULL.
Step 2 - Check whether list is Empty (head == NULL)
Step 3 - If it is Empty then, assign NULL to newNode → next and newNode to head.
Step 4 - If it is not Empty then, assign head to newNode → next and newNode to head.
Step 1 - Create a newNode with given value and newNode → next as NULL.
Step 2 - Check whether list is Empty (head == NULL)
Step 3 - If it is Empty, then assign NULL to newNode → previous and newNode to head.
Step 4 - If it is not Empty, then, define a node pointer temp and initialize with head.
Step 5 - Keep moving the temp to its next node until it reaches to the last node in the list
(until temp → next is equal to NULL).
Step 6 - Assign newNode to temp → next and temp to newNode → previous.
Deletion
In a double linked list, the deletion operation can be performed in three ways as follows...
We traverse a circular singly linked list until we reach the same node where
we started. The circular singly liked list has no beginning and no ending.
There is no null value present in the next part of any of the nodes.
Circular linked list are mostly used in task maintenance in operating systems. There
are many examples where circular linked list are being used in computer science
including browser surfing where a record of pages visited in the past by the user, is
maintained in the form of circular linked lists and can be accessed again on clicking
the previous button.
Memory Representation of circular linked list:
In the following image, memory representation of a circular linked list
containing marks of a student in 4 subjects. However, the image shows a
glimpse of how the circular list is being stored in the memory. The start or
head of the list is pointing to the element with the index 1 and containing 13
marks in the data part and 4 in the next part. Which means that it is linked
with the node that is being stored at 4th index of the list.
However, due to the fact that we are considering circular linked list in the
memory therefore the last node of the list contains the address of the first
node of the list.
Insertion on a Circular Linked List
We can insert elements at 3 different positions of a circular linked list:
store the address of the current first node in the newNode (i.e. pointing
the newNode to the current first node)
point the last node to newNode (i.e making newNode as head)
store the address of the head node to next of newNode (making newNode the
last node)
point the current last node to newNode
store the address of the node next to the last node in temp
Write UNDERFLOW
Go to Step 8
[END OF IF]
Step 8: EXIT
Tree is a non-linear data structure which organizes data in a hierarchical structure and
this is a recursive definition.
OR
A tree is a connected graph without any circuits.
OR
If in a graph, there is one and only one path between every pair of vertices, then graph is
called as a tree.
Properties-
Tree Terminology-
1. Root-
The first node from where the tree originates is called as a root node.
In any tree, there must be only one root node.
We can never have multiple root nodes in a tree data structure.
Example-
2. Edge-
Example-
3. Parent-
The node which has a branch from it to any other node is called as a parent node.
In other words, the node which has one or more children is called as a parent node.
In a tree, a parent node can have any number of child nodes.
Example-
Here,
Node A is the parent of nodes B and C
Node B is the parent of nodes D, E and F
Node C is the parent of nodes G and H
Node E is the parent of nodes I and J
Node G is the parent of node K
4. Child-
Example-
Here,
Nodes B and C are the children of node A
Nodes D, E and F are the children of node B
Nodes G and H are the children of node C
Nodes I and J are the children of node E
Node K is the child of node G
5. Siblings-
Example-
Here,
Nodes B and C are siblings
Nodes D, E and F are siblings
Nodes G and H are siblings
Nodes I and J are siblings
6. Degree-
Here,
Degree of node A = 2
Degree of node B = 3
Degree of node C = 2
Degree of node D = 0
Degree of node E = 2
Degree of node F = 0
Degree of node G = 1
Degree of node H = 0
Degree of node I = 0
Degree of node J = 0
Degree of node K = 0
7. Internal Node-
The node which has at least one child is called as an internal node.
Internal nodes are also called as non-terminal nodes.
Every non-leaf node is an internal node.
Example-
8. Leaf Node-
The node which does not have any child is called as a leaf node.
Leaf nodes are also called as external nodes or terminal nodes.
Example-
Here, nodes D, I, J, F, K and H are leaf nodes.
9. Level-
Example-
10. Height-
Total number of edges that lies on the longest path from any leaf node to a particular
node is called as height of that node.
Height of a tree is the height of root node.
Height of all leaf nodes = 0
Example-
Here,
Height of node A = 3
Height of node B = 2
Height of node C = 2
Height of node D = 0
Height of node E = 1
Height of node F = 0
Height of node G = 1
Height of node H = 0
Height of node I = 0
Height of node J = 0
Height of node K = 0
11. Depth-
Total number of edges from root node to a particular node is called as depth of that
node.
Depth of a tree is the total number of edges from root node to a leaf node in the longest
path.
Depth of the root node = 0
The terms “level” and “depth” are used interchangeably.
Example-
Here,
Depth of node A = 0
Depth of node B = 1
Depth of node C = 1
Depth of node D = 2
Depth of node E = 2
Depth of node F = 2
Depth of node G = 2
Depth of node H = 2
Depth of node I = 3
Depth of node J = 3
Depth of node K = 3
12. Subtree-
Example-
13. Forest-
Example-
Applications of trees
The following are the applications of trees:
o Storing naturally hierarchical data: Trees are used to store the data in
the hierarchical structure. For example, the file system. The file system
stored on the disc drive, the file and folder are in the form of the naturally
hierarchical data and stored in the form of trees.
o Organize data: It is used to organize data for efficient insertion, deletion
and searching. For example, a binary tree has a logN time for searching an
element.
o Trie: It is a special kind of tree that is used to store the dictionary. It is a fast
and efficient way for dynamic spell checking.
o Heap: It is also a tree data structure implemented using arrays. It is used to
implement priority queues.
o B-Tree and B+Tree: B-Tree and B+Tree are the tree data structures used to
implement indexing in databases.
o Routing table: The tree data structure is also used to store the data in
routing tables in the routers.
o General tree: The general tree is one of the types of tree data structure. In
the general tree, a node can have either 0 or maximum n number of nodes.
There is no restriction imposed on the degree of the node (the number of
nodes that a node can contain). The topmost node in a general tree is known
as a root node. The children of the parent node are known as subtrees.
There can be n number of subtrees in a general tree. In the general tree, the
subtrees are unordered as the nodes in the subtree cannot be ordered.
Every non-empty tree has a downward edge, and these edges are connected
to the nodes known as child nodes. The root node is labeled with level 0.
The nodes that have the same parent are known as siblings.
o
Binary tree: Here, binary name itself suggests two numbers, i.e., 0 and 1. In
a binary tree, each node in a tree can have utmost two child nodes. Here,
utmost means whether the node has 0 nodes, 1 node or 2 nodes.
o
o
Binary Search tree: Binary search tree is a non-linear data structure in
which one node is connected to n number of nodes. It is a node-based data
structure. A node can be represented in a binary search tree with three fields,
i.e., data part, left-child, and right-child. A node can be connected to the
utmost two child nodes in a binary search tree, so the node contains two
pointers (left child and right child pointer).
Every node in the left subtree must contain a value less than the value of the
root node, and the value of each node in the right subtree must be bigger
than the value of the root node.
o
AVL tree
It is one of the types of the binary tree, or we can say that it is a variant of
the binary search tree. AVL tree satisfies the property of the binary tree as
well as of the binary search tree. It is a self-balancing binary search tree
that was invented by Adelson Velsky Lindas. Here, self-balancing means
that balancing the heights of left subtree and right subtree. This balancing is
measured in terms of the balancing factor.
We can consider a tree as an AVL tree if the tree obeys the binary search tree as
well as a balancing factor. The balancing factor can be defined as
the difference between the height of the left subtree and the height of
the right subtree. The balancing factor's value must be either 0, -1, or 1;
therefore, each node in the AVL tree should have the value of the balancing
factor either as 0, -1, or 1.
A binary tree in which every node has either two or zero number of children is called Strictly
Binary Tree
Strictly binary tree is also called as Full Binary Tree or Proper Binary Tree or 2-Tree
A binary tree in which every internal node has exactly two children and all leaf nodes are at
same level is called Complete Binary Tree.
The full binary tree obtained by adding dummy nodes to a binary tree is called as Extended
Binary Tree.
In above figure, a normal binary tree is converted into full binary tree by adding dummy nodes (In
pink colour).
o B-tree
B-tree is a balanced m-way tree where m defines the order of the tree. Till
now, we read that the node contains only one key but b-tree can have more
than one key, and more than 2 children. It always maintains the sorted data.
In binary tree, it is possible that leaf nodes can be at different levels, but in
b-tree, all the leaf nodes must be at the same level.
The root node must contain minimum 1 key and all other nodes must contain
atleast ceiling of m/2 minus 1 keys.
The above figure shows the inorder traversal of this binary tree yields D, B,
E, A, C, F. When this tree is represented as a right threaded binary tree, the
right link field of leaf node D which contains a NULL value is replaced with a
thread that points to node B which is the inorder successor of a node D. In
the same way other nodes containing values in the right link field will contain
NULL value.
Threaded trees are a important data structure where trees are created
once with very less of insertions and deletions operations there on and
more of traversal operations (specifically depth first traversals) are
more in number. In such situations the threaded trees act as a boon for
the system performance by reducing the space required for stacks.
It is also possible to discover the parent of a node from a threaded
binary tree, without explicit use of parent pointers or a stack, albeit
slowly. This can be useful where stack space is limited, or where a stack
of parent pointers is unavailable (for finding the parent pointer via DFS).
Similarly, we can see the left child of root node is greater than its left child
and smaller than its right child. So, it also satisfies the property of binary
search tree. Therefore, we can say that the tree in the above image is a
binary search tree.
In the above tree, the value of root node is 40, which is greater than its left
child 30 but smaller than right child of 30, i.e., 55. So, the above tree does
not satisfy the property of Binary search tree. Therefore, the above tree is
not a binary search tree.
Suppose the data elements are - 45, 15, 79, 90, 10, 55, 12, 20, 50
o First, we have to insert 45 into the tree as the root of the tree.
o Then, read the next element; if it is smaller than the root node, insert it
as the root of the left subtree, and move to the next element.
o Otherwise, if the element is larger than the root node, then insert it as
the root of the right subtree.
Now, let's see the process of creating the Binary search tree using the given
data element. The process of creating the BST is shown below -
As 15 is smaller than 45, so insert it as the root node of the left subtree.
Step 3 - Insert 79.
As 79 is greater than 45, so insert it as the root node of the right subtree.
90 is greater than 45 and 79, so it will be inserted as the right subtree of 79.
Step 5 - Insert 10.
55 is larger than 45 and smaller than 79, so it will be inserted as the left
subtree of 79.
Step 7 - Insert 12.
12 is smaller than 45 and 15 but greater than 10, so it will be inserted as the
right subtree of 10.
20 is smaller than 45 but greater than 15, so it will be inserted as the right
subtree of 15.
Step 9 - Insert 50.
50 is greater than 45 but smaller than 79 and 55. So, it will be inserted as a
left subtree of 55.
Now, the creation of binary search tree is completed. After that, let's move
towards the operations that can be performed on Binary search tree.
We can perform insert, delete and search operations on the binary search
tree.
1. Search
2. Insertion
3. Deletion
Step 1 - Create a new Node with given value and set its left and right to NULL.
Step 2 - Check whether tree is Empty.
Step 3 - If the tree is Empty, then set root to new Node.
Step 4 - If the tree is Not Empty, then check whether the value of new Node
is smaller or larger than the node (here it is root node).
Step 5 - If new Node is smaller than or equal to the node then move to its left child. If new
Node is larger than the node then move to its right child.
Step 6- Repeat the above steps until we reach to the leaf node (i.e., reaches to NULL).
Step 7 - After reaching the leaf node, insert the new Node as left child if the new Node
is smaller or equal to that leaf node or else insert it as right child.
Example
Construct a Binary Search Tree by inserting the following sequence of numbers...
10,12,5,4,20,8,7,15 and 13
Above elements are inserted into a Binary Search Tree as follows...
AVL Tree
AVL Tree is invented by GM Adelson - Velsky and EM Landis in 1962. The tree
is named AVL in honour of its inventors.
AVL Tree can be defined as height balanced binary search tree in which each
node is associated with a balance factor which is calculated by subtracting
the height of its right sub-tree from that of its left sub-tree.
If balance factor of any node is 0, it means that the left sub-tree and right
sub-tree contain equal height.
If balance factor of any node is -1, it means that the left sub-tree is one level
lower than the right sub-tree.
An AVL tree is given in the following figure. We can see that, balance factor
associated with each node is in between -1 and +1. therefore, it is an
example of AVL tree.
Complexity
Algorithm Average case Worst case
S Operation Description
N
VL tree controls the height of the binary search tree by not letting it to be skewed. The time
taken for all operations in a binary search tree of height h is O(h). However, it can be extended
to O(n) if the BST becomes skewed (i.e. worst case). By limiting this height to log n, AVL tree
imposes an upper bound on each operation to be O(log n) where n is the number of nodes.
AVL Rotations
We perform rotation in AVL tree only in case if Balance Factor is other than -1, 0, and 1.
There are basically four types of rotations which are as follows:
Where node A is the node whose balance Factor is other than -1, 0, 1.
The first two rotations LL and RR are single rotations and the next two
rotations LR and RL are double rotations. For a tree to be unbalanced,
minimum height must be at least 2, Let us understand each rotation
. RR Rotation
When BST becomes unbalanced, due to a node is inserted into the right
subtree of the right subtree of A, then we perform RR rotation, RR rotation is
an anticlockwise rotation, which is applied on the edge below a node having
balance factor -2
2. LL Rotation
When BST becomes unbalanced, due to a node is inserted into the left
subtree of the left subtree of C, then we perform LL rotation, LL rotation is
clockwise rotation, which is applied on the edge below a node having
balance factor 2.
In above example, node C has balance factor 2 because a node A is inserted
in the left subtree of C left subtree. We perform the LL rotation on the edge
below A.
3.LR Rotation
Double rotations are bit tougher than single rotation which has already
explained above. LR rotation = RR rotation + LL rotation, i.e., first RR
rotation is performed on subtree and then LL rotation is performed on full
tree, by full tree we mean the first node from the path of inserted node
whose balance factor is other than -1, 0, or 1.
4. RL Rotation
As already discussed, that double rotations are bit tougher than single
rotation which has already explained above. R L rotation = LL rotation + RR
rotation, i.e., first LL rotation is performed on subtree and then RR rotation is
performed on full tree, by full tree we mean the first node from the path of
inserted node whose balance factor is other than -1, 0, or 1.
1. Insert H, I, J
On inserting the above elements, especially in the case of H, the BST
becomes unbalanced as the Balance Factor of H is -2. Since the BST is right-
skewed, we will perform RR Rotation on node H.
2. Insert B, A
On inserting the above elements, especially in case of A, the BST becomes
unbalanced as the Balance Factor of H and I is 2, we consider the first node
from the last inserted node i.e. H. Since the BST from H is left-skewed, we
will perform LL Rotation on node H.
3. Insert E
On inserting E, BST becomes unbalanced as the Balance Factor of I is 2,
since if we travel from E to I we find that it is inserted in the left subtree of
right subtree of I, we will perform LR Rotation on node I. LR = RR + LL
rotation
5. Insert G
On inserting G, BST become unbalanced as the Balance Factor of H is 2,
since if we travel from G to H, we find that it is inserted in the left subtree of
right subtree of H, we will perform LR Rotation on node I. LR = RR + LL
rotation.
6. Insert K
On inserting K, BST becomes unbalanced as the Balance Factor of I is -2.
Since the BST is right-skewed from I to K, hence we will perform RR Rotation
on the node I.
7. Insert L
On inserting the L tree is still balanced as the Balance Factor of each node is
now either, -1, 0, +1. Hence the tree is a Balanced AVL tree
B Tree
B Tree is a specialized m-way tree that can be widely used for disk access. A
B-Tree of order m can have at most m-1 keys and m children. One of the
main reason of using B tree is its capability to store large number of keys in
a single node and large key values by keeping the height of the tree
relatively small.
It is not necessary that, all the nodes contain the same number of children
but, each node must have m/2 number of nodes.
1. Compare item 49 with root node 78. since 49 < 78 hence, move to its left
sub-tree.
2. Since, 40<49<56, traverse right sub-tree of 40.
3. 49>45, move to right. Compare 49.
4. match found, return.
Searching in a B tree depends upon the height of the tree. The search
algorithm takes O(log n) time to search any element in a B tree.
Inserting
Insertions are done at the leaf node level. The following algorithm needs to
be followed in order to insert an item into B Tree.
1. Traverse the B Tree in order to find the appropriate leaf node at which the
node can be inserted.
2. If the leaf node contain less than m-1 keys then insert the element in the
increasing order.
3. Else, if the leaf node contains m-1 keys, then follow the following steps.
o Insert the new element in the increasing order of elements.
o Split the node into the two nodes at the median.
o Push the median element upto its parent node.
o If the parent node also contain m-1 number of keys, then split it too by
following the same steps.
Example:
Insert the node 8 into the B Tree of order 5 shown in the following image.
Deletion
Deletion is also performed at the leaf nodes. The node which is to be deleted
can either be a leaf node or an internal node. Following algorithm needs to
be followed in order to delete a node from a B tree.
If the the node which is to be deleted is an internal node, then replace the
node with its in-order successor or predecessor. Since, successor or
predecessor will always be on the leaf node hence, the process will be similar
as the node is being deleted from the leaf node.
Example 1
Delete the node 53 from the B Tree of order 5 shown in the following figure.
53 is present in the right child of element 49. Delete it.
Now, 57 is the only element which is left in the node, the minimum number
of elements that must be present in a B tree of order 5, is 2. it is less than
that, the elements in its left and right sub-tree are also not sufficient
therefore, merge it with the left sibling and intervening element of parent i.e.
49.
1. The search starts from the root node. Compare the search element k with the root.
1.1. If root node contains k, search completes.
1.2. If k < the first value in the root, we move to the leftmost chld and search the child
recursively.
1.3.1. If the root has just 2 children, then move to the rightmost child and search the
child recursively.
1.3.2. If the root has more than 2 keys, then search the rest.
2. If k is not found after traversing the whole tree, then the search element is not present in
the B Tree.
Application of B tree
B tree is used to index the data and provides fast access to the actual data
stored on the disks since, the access to value stored in a large database that
is stored on a disk is a very time consuming process.
B+ Tree
B+ tree is an extension of the B tree. The difference in B+ tree and B tree is that in B tree
the keys and records can be stored as internal as well as leaf nodes whereas in B+ trees,
the records are stored as leaf nodes and the keys are stored only in internal nodes.
The records are linked to each other in a linked list fashion. This arrangement makes the
searches of B+ trees faster and efficient. Internal nodes of the B+ tree are called index
nodes.
The B+ trees have two orders i.e. one for internal nodes and other for leaf or external
nodes.
As B+ tree is an extension of B-tree, the basic operations that we discussed under the topic
B-tree still holds.
While inserting as well as deleting, we should maintain the basic properties of B+ Trees
intact. However, deletion operation in the B+ tree is comparatively easier as the data is
stored only in the leaf nodes and it will be deleted from the leaf nodes always.
Advantages of B+ Trees
We can fetch records in an equal number of disk accesses.
Compared to the B tree, the height of the B+ tree is less and remains balanced.
We use keys for indexing.
Data in the B+ tree can be accessed sequentially or directly as the leaf nodes are
arranged in a linked list.
Search is faster as data is stored in leaf nodes only and as a linked list.
Data is stored in leaf nodes as well as internal nodes. Data is stored only in leaf nodes.
Searching is a bit slower as data is stored in internal as well Searching is faster as the data is stored only in the leaf nodes.
as leaf nodes.
No redundant search keys are present. Redundant search keys may be present.
Deletion operation is complex. Deletion operation is easy as data can be directly deleted from
the leaf nodes.
Leaf nodes cannot be linked together. Leaf nodes are linked together to form a linked list.