0% found this document useful (0 votes)
35 views49 pages

DS Unit-5 Trees

Uploaded by

asdflkj.amrutha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views49 pages

DS Unit-5 Trees

Uploaded by

asdflkj.amrutha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

15-10-2024

SYLLABUS
UNIT 1: Data Structures and Algorithms Basics (8 Hours)
Introduction: Basic terminologies, elementary data organizations, data structure operations;
abstract data types (ADT) and their characteristics.
Algorithms: Definition, characteristics, analysis of an algorithm, asymptotic notations, time
and space trade-offs.
Array ADT: Definition, operations and representations – row-major and column- major.

UNIT 2: Sorting, Searching and Hashing (10 Hours)


Sorting: Different approaches to sorting, properties of different sorting algorithms (insertion,
Shell, quick, merge, heap, counting), performance analysis and comparison.
Searching: Necessity of a robust search mechanism, searching linear lists (linear search,
binary search) and complexity analysis of search methods.
Hashing: Hash functions and hash tables, closed and open hashing, randomization methods
(division method, mid-square method, folding), collision resolution techniques.
1

SYLLABUS Text/Reference Books


UNIT 3: Stacks and Queues (8 Hours)
Stack ADT: Allowable operations, algorithms and their complexity analysis, applications of stacks–expression
1. G.A.V. Pai, Data Structures and Algorithms: Concepts, Techniques and Application, First
conversion and evaluation (algorithmic analysis), multiple stacks. Edition, McGraw Hill, 2017.
Queue ADT: Allowable operations, algorithms and their complexity analysis for simple queue and circular 2. Ellis Horowitz, Sartaj Sahni and Susan Anderson-Freed, Fundamentals of Data Structures
queue, introduction to double-ended queues and priority queues. in C, Second Edition, Universities Press, 2008.
3. Mark Allen Weiss, Data Structures and Algorithm Analysis in C, Third Edition, Pearson
UNIT 4: Linked Lists (10 Hours)
Singly Linked Lists: Representation in memory, algorithms of several operations: traversing, searching,
Education, 2007.
insertion, deletion, reversal, ordering, etc. 4. Thomas H Cormen, Algorithms Unlocked, MIT Press, 2013
Doubly and Circular Linked Lists: Operations and algorithmic analysis. 5. Reema Thareja, Data Structures using C, Third Edition, Oxford University Press, 2023
Linked representation of stacks and queues. 6. Narasimha Karumanchi, Data Structures and Algorithms Made Easy: Data Structures and
Algorithmic Puzzles Fifth Edition, Career Monk Publications, 2016.
UNIT 5: Trees and Graphs (8 Hours)
Trees: Basic tree terminologies, binary tree and operations, binary search tree (BST) and operations with time
7. Aditya Bhargava, Grokking Algorithms: An Illustrated Guide for Programmers and Other
analysis of algorithms, threaded binary trees. Curious People, First Edition, Manning Publications, 2016.
Self-balancing Search Trees: Tree rotations, AVL tree and operations, 8. K. R. Venugopal and Sudeep R. Prasad, Mastering C, Second Edition, McGraw Hill,
Graphs: Basic terminologies, representation of graphs, traversals (DFS, BFS) with complexity analysis, path 2015.
finding (Dijkstra's SSSP, Floyd's APSP), and spanning tree (Prim's and Kruskal's algorithms). 9. A. K. Sharma, Data Structures using C, Second Edition, Pearson Education, 2013.

Dr. Amit Pimpalkar, RCOEM, Nagpur 1


15-10-2024

Trees
Course Outcomes

On completion of the course the student will be able to


1. Identify different ADTs, their operations and specify their
complexities.
2. Apply linear data structures to address practical challenges and
analyze their complexity.
3. Implement different sorting, searching, and hashing methods and
analyze their time and space requirements.
4. Analyse non-linear data structures to develop solutions for real-
world applications.

Trees in real life Trees in Data Structure 6

Tree Definition Example: Descendant Tree


Tree is a non-linear data structure which organizes data in hierarchical structure.

• Trees are used to represent


hierarchical relationship
node
• Each tree consists of nodes
and edges
• Each node represents an
object
• Each edge represents the
relationship between two
edge nodes.

7 8

Dr. Amit Pimpalkar, RCOEM, Nagpur 2


15-10-2024

Example: Computer File System Example: Computer Parts

Root directory of C drive

Documents and Settings Program Files My Music

Desktop Favorites Start Menu Adobe Microsoft Office

9 10 10

Example: Classification of Data Structure Example: Classification of Data Structure

Data structure Non-Primitive DS

Primitive DS Non-Primitive DS Linear List Non-Linear List

Integer Float Character Pointer Array Queue Graph Trees

Link List Stack


11 12

Dr. Amit Pimpalkar, RCOEM, Nagpur 3


15-10-2024

Example: Table of Contents Example: Java’s Class Hierarchy

Object
Data Structures Using C++

...
Introduction Analysis of Algorithms Index Array Throwable Rectangle String

History Data Algorithm Big Oh Error Exception Square


Time Complexity
Structures Efficiency Notation . .
. .
. .

13 14

Example: Business Company Hierarchy Example: Organization Structure at RCOEM

15 16

Dr. Amit Pimpalkar, RCOEM, Nagpur 4


15-10-2024

Tree terminology... 2. Edge


 In a tree data structure, the connecting link between any two nodes is called as EDGE.
 1.Root:
 In a tree with 'N' number of nodes there will be a maximum of 'N-1' number of edges.
 The first node is called as Root Node.
 Every tree must have root node, there must be only one root node.
 Root node doesn't have any parent.

17 18

3. Parent 4. Child
 In a tree data structure, the node which is predecessor of any node is called as PARENT NODE.  The node which has a link from its parent node is called as child node.
 In simple words, the node which has branch from it to any other node is called as parent node.  In a tree, any parent node can have any number of child nodes.
 Parent node can also be defined as "The node which has child / children".
 In a tree, all the nodes except root are child nodes.

19 20

Dr. Amit Pimpalkar, RCOEM, Nagpur 5


15-10-2024

5. Siblings 6. Leaf Node


 The nodes with same parent are called as Sibling nodes.  The node which does not have a child is called as LEAF Node.
 The leaf nodes are also called as External Nodes or 'Terminal' node.

21 22

7. Internal Nodes 8. Degree


 An internal node is a node with at least one child.
 In a tree data structure, the total number of children of a node is called as
DEGREE of that Node.
 Nodes other than leaf nodes are called as Internal Nodes.
 The root node is also said to be Internal Node if the tree has more than one node.
A 4
 Internal nodes are also called as 'Non-Terminal' nodes.

B 2 C 0 D 0 E 3

F 1 G 0 H 1 I 0 J 1

K 0 L 0 M 0
23 24

Dr. Amit Pimpalkar, RCOEM, Nagpur 6


15-10-2024

9. Height 10. Level


 The total number of edges from leaf node to a particular node in the longest path is called  In a tree data structure, the root node is said to be at Level 0 and the children of root node are
as HEIGHT of that Node. at Level 1 and the children of the nodes which are at Level 1 will be at Level 2 and so on...
 In a tree, height of the root node is said to be height of the tree.  In a tree each step from top to bottom is called as a Level and the Level count starts with '0'
and incremented by one at each level (Step).

Level 0

Level 1

height=3
Level 2

Level 3

25 26

11. Depth 12. Path


 In a tree data structure, the total number of edges from root node to a particular node is  In a tree data structure, the sequence of Nodes and Edges from one node to another node is called as PATH
between that two Nodes.
called as DEPTH of that Node.
 Length of a Path is total number of nodes in that path. In below example the path A - B - E - J has length 4.

27 28

Dr. Amit Pimpalkar, RCOEM, Nagpur 7


15-10-2024

13. Sub Tree


Type of Trees
 Every child node will form a subtree on its parent node.
• General tree
• Binary tree
• Binary Search Tree

29 30

General Tree What is a Binary Tree


• A general tree is a data structure in that each node can have infinite number of children .
• In general tree, root has in-degree 0 and maximum out-degree n. • A binary tree is a collection of nodes that consists of the root and other
• Height of a general tree is the length of longest path from root to the leaf of tree. subsets to the root points, which are called the left and right subtrees.
• Height(T) = {max(height(child1) , height(child2) , … height(child-n) ) +1}
• Every parent node on a binary tree can have up to two child nodes (roots of
the two subtrees); any more children and it becomes a general tree.

• A node that has no children is called a leaf node.

31 32

Dr. Amit Pimpalkar, RCOEM, Nagpur 8


15-10-2024

A Few Terms Regarding Binary Trees This is NOT A Binary Tree


A A

B C B C

D E F
D E F G H
A is the root
B and C are A’s children
A is B’s parent G This is a general tree because C has three child nodes
B & C are the root of two subtrees
D, E, and G are leaves
33 34

This is NOT A Binary Tree Memory Tree Representation (Linked List)


A
A
B C B C

D E F G
D E F

struct node { struct Node* createNode(int value) {


H int data; struct Node* newNode = (struct Node*)malloc(sizeof(struct
struct node *Left_Child; Node));
struct node * Right_Child; newNode->data = value;
This is a graph newNode->left = NULL;
};
because A, B, E, H, F and C form a circuit newNode->right = NULL;
struct node *tree;
35 return newNode; 36

Dr. Amit Pimpalkar, RCOEM, Nagpur 9


15-10-2024

Algorithm for Creation/Insertion of Binary Tree Applications of binary tree


• Data Structure for Search Operations: Binary Search Trees (BST) are used for efficient
Step 1: [check whether the tree is empty]
searching, insertion, and deletion operations allowing for O(log n) average time complexity.
IF Root = NULL
• Hierarchical Data Representation: Binary trees are used to represent hierarchical structures
Root = Create a Node
like organizational charts, file systems, and XML/HTML document structures.
Left_Child [Root] = NULL
• Memory Management: Binary trees are employed in some dynamic memory allocation
Right_Child [Root] = NULL
techniques, managing free and allocated memory blocks.
Step 2: [Test for the left child]
• Expression Parsing and Evaluation: Expression trees represent expressions in compilers
If data < data [Root]
and calculators, facilitating the evaluation of mathematical expressions and parsing.
Left_Child [Root] = Call Create_Tree
• Sorting Algorithms: Binary trees can be used in sorting algorithms, such as tree sort, where
(Left_Child [Root], data)
data is inserted into a binary search tree and then traversed in order.
Else
• Priority Queues: Binary heaps (complete binary trees) are used to implement priority
Right_Child [Root] = Call Create_Tree
queues, which allow for efficient retrieval of the highest (or lowest) priority element.
(Right_Child [Root ], data)
• Routing Tables in Networking: Binary trees can be used to maintain routing tables,
Step 3: Return (Root)
allowing for efficient lookups and updates in network routing protocols.
Step 4: EXIT
• Network Protocols: Certain network protocols utilize binary trees for efficient data
37
distribution and routing, particularly in multicast and broadcast applications. 38

Applications of binary tree


Tree Traversal
• Autocompleting Systems: Binary trees can be used in auto completion algorithms, where
they help in efficiently searching and suggesting words based on prefixes. • There are three common ways to traverse a tree:
• Database Indexing: Binary trees (especially B-trees and their variants) are widely used in
database indexing to facilitate quick data retrieval. – Preorder: Visit the root, traverse the left subtree (preorder) and then
• Artificial Intelligence: In AI, binary trees are used in search algorithms, such as minimax traverse the right subtree (preorder)
trees in game playing, to evaluate possible future states and make decisions. – Postorder: Traverse the left subtree (postorder), traverse the right subtree
• Game Development: Binary trees, such as decision trees, are used in AI for game state (postorder) and then visit the root.
management, enabling efficient decisions based on player moves and strategies.
• Image Processing: Quad-trees (a variation of binary trees) are used for image – Inorder: Traverse the left subtree (in order), visit the root and the traverse
representation and processing, allowing efficient image segmentation and region the right subtree (in order).
representation.
• Huffman Coding Trees: Used in data compression algorithms, Huffman trees are binary
trees that represent variable-length codes for encoding characters based on their
frequencies.

39 40

Dr. Amit Pimpalkar, RCOEM, Nagpur 10


15-10-2024

Tree Traversal Algorithm


Tree Traversals: An Example
A

B C
PRE-ORDER TRAVERSAL IN-ORDER TRAVERSAL

D E F

Preorder: ABDECFG
Postorder: DEBGFCA G
In Order: DBEAFGC

POST-ORDER TRAVERSAL
41 42

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Preorder: A Preorder: AB
(visit each node as your reach it) G (visit each node as your reach it) G

43 44

Dr. Amit Pimpalkar, RCOEM, Nagpur 11


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Preorder: ABD Preorder: ABDE


(visit each node as your reach it) G (visit each node as your reach it) G

45 46

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Preorder: ABDEC Preorder: ABDECF


(visit each node as your reach it) G (visit each node as your reach it) G

47 48

Dr. Amit Pimpalkar, RCOEM, Nagpur 12


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Preorder: ABDECFG Postorder:


(visit each node as your reach it) G G

49 50

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Postorder: Postorder: D
G G

51 52

Dr. Amit Pimpalkar, RCOEM, Nagpur 13


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Postorder: DE Postorder: DEB


G G

53 54

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Postorder: DEB Postorder: DEB


G G

55 56

Dr. Amit Pimpalkar, RCOEM, Nagpur 14


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Postorder: DEBG Postorder: DEBGF


G G

57 58

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

Postorder: DEBGFC Postorder: DEBGFCA


G G

59 60

Dr. Amit Pimpalkar, RCOEM, Nagpur 15


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

G G
In Order: In Order:

61 62

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

G G
In Order: D In Order: DB

63 64

Dr. Amit Pimpalkar, RCOEM, Nagpur 16


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

G G
In Order: DBE In Order: DBEA

65 66

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

G G
In Order: DBEA In Order: DBEAF

67 68

Dr. Amit Pimpalkar, RCOEM, Nagpur 17


15-10-2024

Tree Traversals: An Example Tree Traversals: An Example


A A

B C B C

D E F D E F

G G
In Order: DBEAFG In Order: DBEAFGC

69 70

Tree Traversals: An Example Tree Traversals: Another Example

A A

B C B C

D E
D E F G

F
Preorder: ABDECFG
Postorder: DEBGFCA Preorder: ABDFHIECG
G
In Order: DBEAFGC Postorder: HIFDEBGCA
H I In Order: DHFIBEACG
71 72

Dr. Amit Pimpalkar, RCOEM, Nagpur 18


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example

A A

B C B C

D E D E
G G

F F
Preorder: A Preorder: AB

H I H I
73 74

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F
Preorder: ABD Preorder: ABDF

H I H I
75 76

Dr. Amit Pimpalkar, RCOEM, Nagpur 19


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F
Preorder: ABDFH Preorder: ABDFHI

H I H I
77 78

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F
Preorder: ABDFHIE Preorder: ABDFHIEC

H I H I
79 80

Dr. Amit Pimpalkar, RCOEM, Nagpur 20


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F
Preorder: ABDFHIECG
Postorder:
H I H I
81 82

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: Postorder:
H I H I
83 84

Dr. Amit Pimpalkar, RCOEM, Nagpur 21


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: Postorder: H
H I H I
85 86

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: HI Postorder: HIF


H I H I
87 88

Dr. Amit Pimpalkar, RCOEM, Nagpur 22


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: HIFD Postorder: HIFDE


H I H I
89 90

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: HIFDEB Postorder: HIFDEB


H I H I
91 92

Dr. Amit Pimpalkar, RCOEM, Nagpur 23


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: HIFDEBG Postorder: HIFDEBGC


H I H I
93 94

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

Postorder: HIFDEBGCA
H I H I In Order:
95 96

Dr. Amit Pimpalkar, RCOEM, Nagpur 24


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

H I In Order: H I In Order: D
97 98

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

H I In Order: D H I In Order: DH
99 100

Dr. Amit Pimpalkar, RCOEM, Nagpur 25


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

H I In Order: DHF H I In Order: DHFI


101 102

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

H I In Order: DHFIB H I In Order: DHFIBE


103 104

Dr. Amit Pimpalkar, RCOEM, Nagpur 26


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A A

B C B C

D E D E
G G

F F

H I In Order: DHFIBEA H I In Order: DHFIBEAC


105 106

Tree Traversals: Another Example


Tree Traversals: Another Example
A

B C
 Preorder traversal (NLR)
D E 16,10,5,14,25,18,90
G  Inorder traversal(LNR)
F 5,10,14,16,18,25,90
 Postorder traversal(LRN)
5,14,10,18,90,25,16
H I In Order: DHFIBEACG
107 108

Dr. Amit Pimpalkar, RCOEM, Nagpur 27


15-10-2024

Tree Traversals: Another Example Tree Traversals: Another Example


A

B C
Preorder traversal (NLR) D E
P,H,A,D,K,M,S,R,T,W
G
Inorder traversal(LNR)
A,D,H,K,M,P,R,T,S,W F
Postorder traversal(LRN) Preorder: ABDFHIECG
D,A,M,K,H,T,R,W,S,P
Postorder: HIFDEBGCA
H I
In Order: DHFIBEACG
109 110

preorder: ABCDEFGHI Implementations


inorder: BCAEDGH FI
A A void inorder (node *root)
{
if (root != NULL)
B, C D, E, F, G, H, I B D {
void preorder (node *root) inorder (root->left); void postorder (node *root)
A { printf (“%d “, root- {
C E F if (root != NULL) if (root != NULL)
>element);
{ inorder (root->right); {
B D, E, F, G, H, I G printf (“%d “, root- } postorder (root->left);
I >element); } postorder (root->right);
preorder (root->left); printf (“%d “, root-
preorder (root->right); >element);
C H
} }
} } 112
111 112

Dr. Amit Pimpalkar, RCOEM, Nagpur 28


15-10-2024

Tree Algorithms Tree Algorithms

113 114

Tree Algorithms Tree Program


// Define the structure for a tree node // Function to insert a value into the binary tree
struct TreeNode { struct TreeNode* insert(struct TreeNode* root, int value)
int value; {
struct TreeNode* left; // If the tree is empty, return a new node
struct TreeNode* right; if (root == NULL) {
}; return createNode(value);
}
// Function to create a new tree node
struct TreeNode* createNode(int value) { // Otherwise, recur down the tree
struct TreeNode* newNode = (struct if (value < root->value) {
TreeNode*)malloc(sizeof(struct TreeNode)); root->left = insert(root->left, value);
newNode->value = value; } else {
newNode->left = NULL; root->right = insert(root->right, value);
newNode->right = NULL; }
return newNode;
} // Return the unchanged root pointer
return root;
}

115 116

Dr. Amit Pimpalkar, RCOEM, Nagpur 29


15-10-2024

Tree Program
// Main function to demonstrate tree insertion A case study (Application) :: Expression Tree
// Function to print the tree in-order (for verification) int main() {
void inOrderTraversal(struct TreeNode* root) { struct TreeNode* root = NULL; *
if (root != NULL) {
inOrderTraversal(root->left); // Insert values into the tree
printf("%d ", root->value); root = insert(root, 45); + -
Represents the expression:
inOrderTraversal(root->right); root = insert(root, 30); (a + b) * (c – (d + e))
} root = insert(root, 97);
} root = insert(root, 12);
root = insert(root, 43); a b c +
root = insert(root, 69);
root = insert(root, 83);
d e
// Print the in-order traversal of the tree
printf("In-order traversal of the binary tree:\n");
inOrderTraversal(root); Preorder traversal :: * + a b - c + d e
printf("\n");
Postorder traversal :: a b + c d e + - *
return 0;
} 117 118

Threaded Binary Trees Threaded Binary Trees


• On carefully examining the linked representation of a binary tree T , we will There are many ways to thread a binary tree:
find that approximately half of the pointer fields contains NULL entries. • The right NULL pointer of each node can be replaced by a thread to the
• The space occupied by these NULL entries can be utilized to store some kind successor of the node under in-order traversal called a right thread, and
of valuable information. the tree will called a right threaded tree.
• One way to utilize this space is that we can store special pointer that points to • The left NULL pointer of each node can be replaced by a thread to the
nodes higher in the tree, i.e. ancestors. predecessor of the node under in-order traversal called a left thread, and
the tree will called a left threaded tree.
• These special pointer are called threads, and the binary tree having such • Both left and right NULL pointers can be used to point to predecessor and
pointers is called a threaded binary tree. successor of that node respectively, under in-order traversal. Such a tree is
• In computer memory, an extra field, called tag or flag is used to distinguish called a fully threaded tree.
thread from a normal pointer. • A threaded binary tree where only one thread is used is known as one
way threaded tree and where both thread are used called two way
threaded tree.
119 120

Dr. Amit Pimpalkar, RCOEM, Nagpur 30


15-10-2024

Right threaded binary tree (one way threading) Left threaded binary tree (one way threading)
A
A

B C
B C

X F G X D E X
X F G X D X E X

H X
X H

121 122

Fully threaded binary tree (two way threading) A Threaded Binary Tree
root
A A

dangling
B C
B C

X F G D E X
dangling F G
D E

H
inorder traversal:
H, D, I, B, E, A, F, C, G
H I
123 124

Dr. Amit Pimpalkar, RCOEM, Nagpur 31


15-10-2024

Memory Representation of A Threaded Binary Tree


Representation of threaded binary tree in memory
root typedef struct nodetype
{
struct nodetype *left;
f A f
int info;
char thread;
f B f f C f
struct nodetype *right;
}TBST;
f D f t E t t F t t G t TBST *root;

t H t t I t In this representation, we have used char field thread as a tag.


The character ‘0’ will used for normal right pointer and character ‘1’ will be
125
used for thread. 126

Applications of threaded binary tree Traversing a Threaded Binary Tree


Threaded Binary Trees (TBTs) are a type of binary tree that facilitates efficient in-order traversal without the need for a stack
Step 1: Check if the current node has a left child that has not been visited.
or recursion.
• In-order Traversal: TBTs allow for fast in-order traversal, which is useful in applications where data needs to be If a left child exists that has not been visited,
processed in a sorted manner, such as in databases and search algorithms.
• Memory Management: TBTs can be used in memory allocation systems, where the structure allows for quick access to go to Step 2,
free and allocated memory blocks, improving efficiency in dynamic memory management.
• Network Routing and Navigation Systems: In applications that require efficient pathfinding, such as manage routing
else go to Step 3.
tables, allowing for quick lookups, GPS development, TBTs can be used to represent and traverse data efficiently. Step 2: Add the left child in the list of visited nodes.
• Data Compression: TBTs can assist in encoding and decoding processes in data compression algorithms, allowing for
efficient retrieval and traversal of encoded data. Make it as the current node and then go to Step 6.
• Artificial Intelligence: TBTs can be useful in AI for managing decision trees, allowing for efficient exploration of
potential decisions and states in game development or problem-solving applications. Step 3: If the current node has a right child,
• Compilers: In compilers, TBTs can represent abstract syntax trees, allowing for efficient traversal and manipulation of
syntax trees during the parsing and optimization phases.
go to Step 4 else go to Step 5.
• Expression Trees: TBTs can represent mathematical expressions, enabling efficient evaluation and traversal of complex Step 4: Make that right child as current node and go to Step 6.
expressions in calculators and computer algebra systems.
• File Systems: Some file systems use threaded trees to maintain directory structures, allowing for quick access to files and Step 5: Print the node and if there is a threaded node make it the current node.
directories without excessive overhead.
• Event Scheduling: In real-time systems, TBTs can be used for managing events or tasks, allowing for quick insertion,
Step 6: If all the nodes have visited then END else go to Step 1.
deletion, and traversal of scheduled tasks based on their priorities. 127 128

Dr. Amit Pimpalkar, RCOEM, Nagpur 32


15-10-2024

Heap Sort
Max Heap Example Min heap example
A max heap provides an efficient way to retrieve the maximum elements from an array.
The root of the heap is always the largest element since all child nodes must have smaller values.
19 1
Definition
• Max Heap
12 16 4 16
– Store data in ascending order
– Has property of
12 19
A[Parent(i)] ≥ A[i] (Parent Node is ≥ Child Nodes) 4 7
7
1
• Min Heap
– Store data in descending order
19 12 16 1 4 7 1 4 16 7 12 19
– Has property of
Array A
A[Parent(i)] ≤ A[i] (Parent Node is ≤ Child Nodes) Array A
129 130

Heap Sort The heap property


A max heap provides an efficient way to retrieve the maximum elements from an array.
A node has the heap property if the value in the node is as large as or larger
The root of the heap is always the largest element since all child nodes must have smaller values.
than the values in its children
STEPS OF A HEAP SORT ALGORITHM
1. Transform the array into a binary tree by inserting each element as a node in a breadth- 12 12 12
first manner.
2. Convert the binary tree into a max heap, ensuring that all parent nodes are greater than 8 3 8 12 8 14
or equal to their child nodes.
Blue node has Blue node has Blue node does not
3. Swap the root node — the largest element — with the last element in the heap.
4. Call the heapify() function to restore the max heap property. heap property heap property have heap property
5. Repeat steps 3 and 4 until the heap is sorted, and exclude the last element from the heap
on each iteration. • All leaf nodes automatically have the heap property
6. After each swap and heapify() call, ensure that the max heap property is satisfied. • A binary tree is a heap if all nodes in it have the heap property

131 132

Dr. Amit Pimpalkar, RCOEM, Nagpur 33


15-10-2024

Constructing a heap tree Constructing a heap tree


• A tree consisting of a single node is automatically a heap • Each time we add a node, we may destroy the heap property of its parent
• We construct a heap by adding nodes one at a time: node
• Add the node just to the right of the rightmost node in the deepest level • To fix this, we sift up
• If the deepest level is full, start a new level (Make it Complete Binary Tree)
• But each time we sift up, the value of the topmost node in the sift may
• Examples:
increase, and this may destroy the heap property of its parent node
Add a new node Add a new node
here here • We repeat the sifting up process, moving up in the tree, until either
• We reach nodes whose values don’t need to be swapped (because the parent
is larger than both children), or
• We reach the root

133 134

The heap property: siftUp 19


Heap Sort (Max Heap) 19
• Given a node that does not have the heap property, you can give it the heap property by
exchanging its value with the value of the larger child 12 16
12 16

12 14
1 4 7 1 4 7 17

8 14 8 12 Insert 17
19

Blue node does not have heap property Blue node has heap property
12 17
swap
• This is sometimes called sifting up
1 4 7 16

Swap/Sift/Percolate up to maintain the heap property


135 136

Dr. Amit Pimpalkar, RCOEM, Nagpur 34


15-10-2024

Heap Sort (Max Heap) Heap Sort (Max Heap)


16 16
Example: Convert the following array to a heap 16 4 7 1 12 19
Picture the array as a complete binary tree:
4 7 4 19
16 swap

1 12 19 1 12 7

4 7
16 19
swap swap

12 19 12 16
1 12 19

1 4 7 1 4 7
137 138

Example of Heap Sort (Max Heap) Array A 7 12 16 1 4 Example of Heap Sort


Algorithms Steps: 16
19 7
swap
Step1: Make the max heap tree as per given array
Step2: Write the tree array as level wise sorted (array A)
HEAPIFY() 12 7
12 16 Step3: Swap last node value with first node value (array A) 12 16
Step4: Delete last node from (array A) and store in sorted
array in reverse order. 1 4
1 Step5: Repeat steps 1-4 till no element in (array A)
4 7
1 4
Sorted:
Sorted: Array A
Array A
Sorted: 16 12 7 1 4 16 19
19 12 16 1 4 7 19
19
139 140

Dr. Amit Pimpalkar, RCOEM, Nagpur 35


15-10-2024

Example of Heap Sort Example of Heap Sort

HEAPIFY() HEAPIFY() 7
swap 12 1 4
7 swap swap
4 HEAPIFY() swap
HEAPIFY()
7 1 4 1
7 4 7 4
12 4
12 7

1
1
1
Sorted:
Array A
12 Sorted: Sorted:
7 4 1 12 16 19 Array A Array A
Sorted:
Array A 1 7 4 7 4 1 7 12 16 19
12 16 19
4 12 7 1 16 19

141 142

Example of Heap Sort Example of Heap Sort (Max Heap) (Alternate Method)
Algorithms Steps:
swap 1 4
19
Step1: Make the max heap tree as per given array
HEAPIFY() Step2: Write the tree array as level wise sorted (array A)
4 1
12 16 Step3: Swap last node value with first node value (array A)
Step4: Delete last node from (array A) and store in sorted
array in reverse order.
Sorted: Sorted: 1 Step5: Repeat steps 1-4 till no element in (array A)
Array A Array A 4 7
1 4 7 12 16 19
1 4 7 12 16 19
Sorted:
Array A
Sorted: 19 12 16 1 4 7 19
1
1 4 7 12 16 19
143 144

Dr. Amit Pimpalkar, RCOEM, Nagpur 36


15-10-2024

Array A 7 12 16 1 4 Example of Heap Sort Example of Heap Sort


4 12
16 swap
7
swap HEAPIFY()
HEAPIFY() 12 7 12 7 4 7
12 16

1 1 1
4
1 4
Sorted:
Sorted: Array A Sorted:
Array A Array A
4 12 7 1 16 19
Sorted: 12 4 7 1 19
16 12 7 1 4 16 19 12 16
19
145 146

Example of Heap Sort Example of Heap Sort


1 swap 7

swap 1 4
4 7 4 1
HEAPIFY()
4 1

Sorted: Sorted:
Sorted: Array A Array A
Sorted: Array A
Array A 1 4 7 12 16 19
7 4 1 7 12 16 19 4 1 7 12 16 19
1 4 7 12 16 19

Sorted:
1
1 4 7 12 16 19
147 148

Dr. Amit Pimpalkar, RCOEM, Nagpur 37


15-10-2024

Heap Sort Complexity


Heap Sort (Max Heap) Examples
• To reheap the root node, we have to follow one path from the root to a leaf
1) 18, 84, 67, 22, 13, 75 node (and we might stop before we reach a leaf)
2) 12, 79, 34, 56, 15, 48, 90 • The binary tree is perfectly balanced
3) 34, 12, 45, 67, 89, 23, 56, 78, 90, 11, 33 • Therefore, this path is O(log n) long
4) 54, 23, 76, 12, 69, 31, 47, 66, 5, 99, 10 – And we only do O(1) operations at each node
5) 31, 14, 78, 50, 29, 88, 42, 11, 66, 20, 35 – Therefore, reheaping takes O(log n) times
6) 45, 23, 67, 12, 89, 34, 56, 15, 88, 90, 37, 22 • Since we reheap inside a while loop that we do n-1 times, the total time for
7) 21, 47, 33, 85, 62, 76, 54, 10, 39, 28, 99, 43 the while loop is n*O(log n), or O(n log n)
8) 32, 54, 18, 91, 76, 23, 85, 45, 10, 68, 22, 99, 86 • Build Heap Algorithm will run in O(n) time
• Remove and re-heap O(log n)
– Do this n-1 times O(n log n)
• Total time O(n log n) + O(n log n) = O(n log n)
149 150

Balanced and unbalanced BST AVL Tree


4
• AVL trees are nothing but self-balancing binary search trees.
1
• A self-balanced tree means that when we try to insert any element in this
2 BST and if it violates the balancing factor of any node, then it dynamically
2 6
rotates itself accordingly to make itself self-balanced.
3
• It is also well known that dynamically balanced trees.
1 3 5 7
4 • The height of the left and the right subtrees of every node differs by at most
1, which implies the difference between the heights will always be either 1,0
5 or -1.
• So, AVL trees are an optimized version of binary search trees named after its
6 inventors G.M. Abelson-Velvety and E.M. Landis, in 1962.
• It was an attempt to improve the performance of Binary Search Trees.
7

151 152

Dr. Amit Pimpalkar, RCOEM, Nagpur 38


15-10-2024

Why AVL Tree Balance Factor in AVL Trees


• When we already had a similar data structure (i.e. BST's), why would we need a complex Properties of Balance Factor
version of it?. • If the balance factor=0, the subtree is perfectly
• The answer lies in the fact that BST has some limitations in certain scenarios that make balanced, with both left and right subtrees having
some operations like searching, inserting costly (as costly as O(n)). equal heights.
• Consider the pictorial representation of two BST's below: • If a subtree has a balance factor>0, then the subtree
is called left-heavy as the height of the left subtree
• The height of the left BST is O(log n) and the height is greater than the height of its right subtree, so the
of the right BST is O(n), thus the search operation left subtree has more nodes than the right subtree.
time complexity for the left BST is O(log n) and for
• If a subtree has a balance factor<0, then the subtree
the right-skewed is O(n) which is its worst case too.
is called right-heavy as the height of the left subtree
• Hence, if we have such a skewed tree then there's no
benefit of using a BST, as it is just like a linked list is smaller than the height of its right subtree, so the
Balance Factor =
when it comes to time and space complexity. right subtree has more nodes than the left subtree.
height(left subtree) - height(right subtree)
• That's why we needed a balanced BST's so that all
the basic operations guarantee a time complexity of The total number of edges from leaf node to a particular node in the longest
O(log n).
153
path is called as HEIGHT of that Node. 154

AVL Tree Balance Factor in AVL Trees


Balanced AVL tree
Left heavy AVL tree 1
• The tree in figure (a) is an AVL tree. 45 0
1
As you can see, for every node, the 0
45

36 63 0
height difference between its left 36
0
0
subtree and right subtree does not 1 27
39 54 72 0
63

0
exceed mod (1). 0
0
0 0
27
• While in figure (b), if you check the 0 18
39
54 72
-1
node with value 3, its left subtree 45

has height=2 while the right 0 -1

subtree’s height=0. 36 63

0 1
• So, the difference is mod (2-0) = 2. 27
0 0

72

• Hence, the AVL property is not


39 54

Right heavy AVL tree


satisfied, and it is not an AVL tree. 70
0

155 156

Dr. Amit Pimpalkar, RCOEM, Nagpur 39


15-10-2024

AVL Trees Rotations AVL Trees Rotations


Left Rotation (LL - Single Rotation) Right Rotation (RR - Single Rotation)
• Left rotation is performed when the imbalance is created due to the insertion of a new Right rotation is needed when the imbalance is created due to the insertion of a node in the
node in the right subtree of a right subtree or when a subtree becomes right heavy. left subtree of a left subtree or when a subtree becomes left heavy.

Node 6 has a balance factor of -2 after the insertion of node 10. After a single rotation towards Node 3 has a balance factor of 2, so it is unbalanced. After a single rotation towards the right,
the left, node 8 becomes the root and node 6 becomes its left child. node 2 becomes the root and node 3 becomes its right child.
By doing this, the BST property also remains intact, and the tree becomes height-balanced. And the new root, i.e., node 2, has a balance factor of 0. Hence, the tree becomes balanced.
157 158

AVL Trees Rotations AVL Trees Rotations


Left-Right Rotation (LR - Double Rotation) Left-Right Rotation (LR - Double Rotation)
It is a double rotation in which a right rotation follows a left rotation. It is a double rotation in which a right rotation takes place.
It is needed when a new node is inserted in the left subtree of the right subtree of a node. It is needed when a new node is inserted in the left subtree of the left subtree of a node.
Node 1 is inserted as the left child Node 12 inserted to the left of 25 and
of node 2, which is the right child of therefore, it disturbs the Balance
node 5. Factor of the tree.
See that the balance factor of node 5 The tree needs to be rebalanced by
becomes 2 after insertion of node 1. rotating it through LR rotation.
Firstly, we do a left rotation, but the Here, the critical node 100 will be
tree is still not balanced. If you see moved to its right, and the root of its
carefully, the tree is left heavy after left sub-tree.
this step, so we need a right The right sub-tree of with root node
rotation. 75 will be place to the left of Node
After which node 1, i.e. the newly with value 100.
inserted node, becomes the root. Recall term predecessor and
successor.
159 160

Dr. Amit Pimpalkar, RCOEM, Nagpur 40


15-10-2024

AVL Trees Rotations AVL Trees Rotations


Right-Left Rotation (RL - Double Rotation) Right-Left Rotation (RL - Double Rotation)
In this, a right rotation is followed by a left rotation. In this, a right rotation is followed by a left rotation.
It is needed when a node is inserted in the left subtree of the right subtree of a node. It is needed when a node is inserted in the left subtree of the right subtree of a node.

The insertion of node 6 creates Inserting 92 disturbs the


an imbalance. balance factor of the node 92
Firstly, we perform a right and it becomes the critical
rotation which makes node 6 a node with 105 as the node and
parent of node 8 and node 8 95.
becomes the right child of
node 6. In RL rotation, 95 becomes the
Next, we perform left rotation root of the tree with node 90
on the resulting right-heavy and 105 as its left and right
tree and finally, the tree children respectively.
becomes balanced. Recall term predecessor and
161
successor. 162

Insertion in AVL Trees Extended Example of Insertion in AVL Trees


Insert 50, 25, 10, 5, 7, 3, 30, 20, 8, 15 into AVL tree

Critical Node is 7, so make in-


order successor node as root
and arrange node accordingly
163 164

Dr. Amit Pimpalkar, RCOEM, Nagpur 41


15-10-2024

Insert 3, 2, 1, 4, 5, 6, 7, 16, 15, 14


Extended Example of Insertion in AVL Trees 2
2

Insert 3, 2, 1, 4, 5, 6, 7, 16, 15, 14


1 4
3 1 4
3 2
3 5
3 3 5
Fig 8
Fig 7 6
2 1
2 3 4
Fig 1 4
Fig 4
2 5
Fig 2 2 5
2 1 2 1 3 6
1 3 6
4
Fig 3 Fig 10 7
1 3 Fig 9
1 3 2 6

Fig 5 Fig 6 4 7
1 3
4 5
5 Fig 11
165 166

Insert 3, 2, 1, 4, 5, 6, 7, 16, 15, 14 Insert 3, 2, 1, 4, 5, 6, 7, 16, 15, 14

4 4
4 4

2 6 2 6
2 2 7
6
1 3 7 1 3 7

15 3 15
16 16 1 3 1 6
5 5 5
Fig 12
Fig 13 16
15
4 7 14 16
5
Fig 15

2 6 14 Fig 16

1 3 15
5
16
7
Fig 14 167 Deletions can be done with similar rotations 168

Dr. Amit Pimpalkar, RCOEM, Nagpur 42


15-10-2024

Deletion Example Advantages of AVL Trees


15 delete 10 15
• The AVL tree is always height-balanced, and its height is always O(log N), where N is the
total number of nodes in the tree.
10 30 5 30 • The time complexities of all the operations are better than BSTs as the AVL tree has the
5 12 17 35 worst-case time complexity of all operations as O(log N), while in BST, it is O(N).
12 17 35
• AVL trees have self-balancing properties.
14 20 31 40 14 20 31 40 • AVL trees are not skewed.
50 50 • AVL trees perform better searching operations than Red-Black Trees
• It shows better search time complexity.

30 15 Application of AVL Tree


15 35 12 30 • Its application is in in-memory and dictionaries to store data.
12 17 31 40 • Database systems frequently use AVL trees as indexes to allow quick data searching and
5 14 17 35
recovery of data functions.
5 14 20 50 20 31 40 • AVL trees operate in networking routing algorithms.
50 • AVL trees encounter applications in interactive storytelling games.
169 170

Introduction to B-Tree Example of B-Tree

• B-trees are balanced search tree.


• More than two children are possible.
• B-Tree, stores all information in the leaves and stores only keys
and Child pointer.
• If an internal B-tree node x contains n[x] keys then x has n[x]+1
children.

171 172

Dr. Amit Pimpalkar, RCOEM, Nagpur 43


15-10-2024

Application of B-Tree
Another example of B-Tree

173
It designed to work on magnetic disks or other (direct access) secondary storage devices. 174

Properties of B-Tree
• A B-Tree T is a rooted tree having the following properties: B-Tree Insertion
1. Every node x has the following fields:
1. n[x] the no. of keys currently stored in node x
1) B-tree starts with a single root node (which is also a leaf node) at level 0.
2. The n[x] keys themselves, stored in non-decreasing order, so that key1[x] ≤ key2[x]…… ≤keyn- 2) Once the root node is full with d–1 search key values and when attempt to
1[x] ≤ keyn[x].
insert another entry in the tree, the root node splits into two nodes at level 1.
3. Leaf[x], a Boolean value that is TRUE if x is a leaf and FALSE if x is an internal node. 3) Only the middle value is kept in the root node, and the rest of the values are
2. Each internal node x also contains n[x]+1 pointers (Childs) c1[x], c2[x],--------- split evenly between the other two nodes.
cn[x]+1[x]. 4) When a non-root node is full and a new entry is inserted into it, that node is
3. All leaves have the same depth, which is the tree’s height h. split into two nodes at the same level, and the middle entry is moved to the
parent node along with two pointers to the new split nodes.
4. There are lower and upper bounds on the no. of keys a node can contains: these
bounds can be expressed in terms of a fixed integer t≥2 called the minimum degree
5) If the parent node is full, it is also split.
of B-Tree. 6) Splitting can propagate all the way to the root node, creating a new level if
– Every node other than the root must have at least t-1 keys, then root has at least t children if the tree is
the root is split.
non empty the root must have at least one key.
– Every node can contain at most 2t-1 keys. Therefore, an internal node can have at most 2t children we
say that a node is full if it contains exactly 2t-1 keys. 175 176

Dr. Amit Pimpalkar, RCOEM, Nagpur 44


15-10-2024

Constructing a B-tree 1
12 Constructing a B-tree
• Suppose we start with an empty B-tree and keys arrive in the 8
2
following order: 1 12 8 2 25 6 14 28 17 7 52 16 48 68 3 25 Add 6 to the tree
6
26 29 53 55 45 14
• We want to construct a B-tree of degree 5 (max d–1 key values) 28
17
• The first four items go into the root: 7
52 Exceeds Order. Promote
16 middle and split.
48
1 2 8 12 68 1 2 8 12 25
3
• To put the fifth item in the root would violate condition 5 26
29
• Therefore, when 25 arrives, pick the middle key to make a new 53
55
root 45

177 178

1 1
12
8
Constructing a B-tree (contd.) 12
8
Constructing a B-tree (contd.)
2 2
25 25
6 8 6 Adding 17 to the right leaf node would over-fill it, so we take
14 14 the middle key, promote it (to the root) and split the leaf
28 28
17 17
7 7 8
52 1 2 12 25 52
16 16
48 6, 14, 28 get added to the leaf nodes: 48
68 68
3 8 3 1 2 62 25 28 28
12 14 17
26 26
29 29
53 53
55 55
45 1 21 62 12 14
25 28 45

179 180

Dr. Amit Pimpalkar, RCOEM, Nagpur 45


15-10-2024

1 1
12
8
Constructing a B-tree (contd.) 12
8
Constructing a B-tree (contd.)
2 2
25 7, 52, 16, 48 get added to the leaf nodes 25
6 6 Adding 68 causes us to split the right most leaf,
14 14
28 28
promoting 48 to the root
17 17
7 8 17 7
52 52
16 16
48 48 8 17
68 68
3 1 2 76 12 1416 25 28 52
48 3
26 26
29 29 1 2 6 7 12 14 16 25 28 48 52 68
53 53
55 55
45 45

181 182

1 1
12
8
Constructing a B-tree (contd.) 12
8
Constructing a B-tree (contd.)
2 2
25 25
6 Adding 3 causes us to split the left most leaf 6 Add 26, 29, 53, 55 then go into the leaves
14 14
28 28
17 8 17 48 17 3 8 17 48
7 7
52 52
16 16
48 48
68 1 23 6 7 12 14 16 25 28 52 68 68 1 2 6 7 12 14 16 25262829 52536855
3 3
26 26
29 29
53 53
55 55
45 45

183 184

Dr. Amit Pimpalkar, RCOEM, Nagpur 46


15-10-2024

1
12 Constructing a B-tree (contd.) Constructing a B+ Tree
8
2
• Suppose we start with an empty B-tree and keys arrive in the
25 Exceeds Order. following order: 1 12 8 2 25 6 14 28 17 7 52 16
6 Add 45 increases the trees level Promote middle and
14 split. • We want to construct a B+ tree of degree 5
28
17 • The first four items go into the root:
7
52 Exceeds Order.
16 3 8 17 48
Promote middle and 1 2 8 12
48 split.
68
3 • To put the fifth item in the root would violate condition 5
26
29 1 2 6 7 12 14 16 25 26 28 29 45 52 53 55 68 • Therefore, when 25 arrives, pick the middle key to make a new
53
55
root
45

185 186

Constructing a B+ Tree Constructing a B+ Tree


• Suppose we start with an empty B+ tree and keys arrive in the • Suppose we start with an empty B+ tree and keys arrive in the
following order: 1 12 8 2 25 6 14 28 17 7 52 16 following order: 1 12 8 2 25 6 14 28 17 7 52 16

187 188

Dr. Amit Pimpalkar, RCOEM, Nagpur 47


15-10-2024

Exercise in Inserting a B+ Tree Exercise in Inserting in a BST, B-Tree, B+ Tree,


• Insert the following keys in B+ tree when t=3 : AVL Tree, Heap Sort, Draw TBT for BST
• 3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56 • Insert the following keys in B-tree when Order = 3, 4 and 5
 42, 22, 12, 82, 62, 52, 9, 32, 102
• Insert the following keys in B+ tree when t=4 :  46, 2, 83, 41, 102, 5, 17, 31, 64, 49, 18
• 3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56  21, 16, 36, 51, 67, 75, 27, 32, 72, 14, 12
• Insert the following keys in B+ tree when t=5 :  90, 66, 57, 33, 87, 82, 13, 76, 14, 45, 38
• 3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56  3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56
 17, 34, 56, 11, 71, 86, 55, 10, 52, 82, 31, 13, 22, 35, 44, 20, 60, 28
• Check your approach with a neighbour and discuss any differences.
Check your approach with a neighbour and discuss any differences.
189 190

DS Online Learning Resources & Simulators


• https://www.cs.usfca.edu/~galles/visualization/Algorithms.html
Question?
• https://yongdanielliang.github.io/animation/animation.html • A good question deserve a good grade…
• https://www.calcont.in/Conversion/infix_to_postfix
• https://csvistool.com/
• https://visualgo.net/en
• https://runestone.academy/ns/books/published/pythonds/index.html
• https://github.com/Lugriz/typescript-algorithms/tree/master
• https://lnogueir.github.io/expression-tree-gen/
• https://cse.iitkgp.ac.in/~rkumar/pds-vlab/index1.html
• https://cse01-iiith.vlabs.ac.in/List%20of%20experiments.html
191 192

Dr. Amit Pimpalkar, RCOEM, Nagpur 48


15-10-2024

193

Dr. Amit Pimpalkar, RCOEM, Nagpur 49

You might also like