0% found this document useful (0 votes)
31 views75 pages

Data Structures Study Material

Uploaded by

skjdkmq518
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)
31 views75 pages

Data Structures Study Material

Uploaded by

skjdkmq518
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/ 75

DATA STRUCTURES

STUDY MATERIAL

Sai Campus Recruitment Training


Gauraverse
@gaurav._.tiwari_
@saicampustraining
2nd floor, above Apoorti Mall, Sector C, Indrapuri, Bhopal.
8319953369, 7987161229
DSA NOTES
DATA STRUCTURES :

Data Structure is a particular way of storing and organizing data in a computer’s memory
so that the data can be efficiently accessed.

What is the need of DATA STRUCTURE?


If we make any program using suitable Data Structure then it will be efficient in terms of
Time and Space complexity.

What are the various types of Data Structure ?


There are two types of Data Structure :
1. Primitive Data Structure.
2. Non-Primitive Data Structure.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
PRIMITIVE DATA STRUCTURE :
Primitive Data Structures are those Data Structures which can
store only single value.
Example : int, float,char, bool, pointer, etc .

NON - PRIMITIVE DATA STRUCTURE :


Non-Primitive Data Structure are those Data Structures which are
not derived from Primitive Data Structures.
They are further categorized into two types:
1. Linear Data Structure.
2. Non-Linear Data Structure.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
LINEAR DATA STRUCTURE :
Those Data Structure in which one element is only connected to
one other element are called Linear Data Structure.

Example : Array, Structure, Stack, Queue, linked list.

NON - LINEAR DATA STRUCTURE :


Those Data Structure in which one element is connected to multiple
element are called Non-Linear Data Structure.

Example : Tree, Graph,Heap

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
ALGORITHM :

It is a step by step sequence to solve any problem, before writing any


program, We first write various algorithm and then we analyse those
algorithms on the basis of time and space complexity. The algorithm
which suits best according to time and space is implemented using a
suitable programming language.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
ASYMPTOTIC NOTATION :

These are the notations which determine the performance of an


algorithm in terms of time and space complexity.

There are Three types of Asymptotic Notation :

1. Best Case (Omega, Ω)-


2. Average Case( Theta, )
3. Worst Case (Big Oh, O )

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

for(i=0;i<n;i++)
{
print(“Sai Campus Recruitment Training”)
}

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(N)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

for(i=0;i<n/2;i++)
{
print(“Sai Campus Recruitment Training”)
}

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(N)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

for(i=1;(i^2)<=n;i++)
{
print(“Sai Campus Recruitment Training”)
}

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(Root n)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

for(i=1;i<=n;i=i*2)
{
print(“Sai Campus Recruitment Training”)
}

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(log n)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
print(“Sai Campus Recruitment Training”)
}
}
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(N^2)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
CALCULATE TIME COMPEXITY DSA NOTES
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
{
print(“Sai Campus Recruitment Training”)
}
}
}
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(N^3)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
CALCULATE TIME COMPEXITY DSA NOTES
for(i=0;i<n;i++)
{
for(j=0;j<n;j=j*2)
{
print(“Sai Campus Recruitment Training”)
}
}

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(n logn)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
CALCULATE TIME COMPEXITY DSA NOTES

for(i=1;i<=n;i++)
{
sum=sum+i
}
print(sum)

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(n)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
CALCULATE TIME COMPEXITY DSA NOTES

n=somevalue
sum=n*(n+1)/2
print(sum)

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(1)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
CALCULATE TIME COMPEXITY DSA NOTES

a=5
b=6
a=a+b
b=a-b
a=a-b
print(a,b)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
CALCULATE TIME COMPEXITY

O(1)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
What is Array ?

Array is the collection of similar datatype stored in continuous


memory location.

In Array, Index always start with 0 and end with n-1 .

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Advantage of Array :
Accessing/Updation: We can access/Update any element of array is constant
time with O(1) time complexity by using the formula,
Formula : Required address = Base address + Index * Size.

Disadvantages of Array :
1. Static Memory Allocation: Array has Static Memory Allocation it means its size
cannot be increased or decreased at runtime .

2. Insertion or Deletion: Insertion and deletion are costly and time consuming
operations in Array because to “insert” any element in the array we have to shift
all the elements after it one position right and to “delete” any element from the
array we have to shift all the elements after it one position left. In both cases time
complexity will be O(n)
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
What is Stack ?

STACK is linear list with the restriction that elements will be inserted and deleted
from only one end of the stack called top of the stack .

Stack is based on the principle of LIFO (last in first out) .

Operations on Stack :
There are three operations associated with the Stack:
1. PUSH : To insert the element into stack .
2. POP : To delete the topmost element from stack .
3. PEEK : To see the Topmost element in the stack .

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Algorithm for PUSH()

• Algorithm PUSH(arr, top, MAXINDEX, data)

Step-1: Check for Overflow,


if (top == MAXINDEX):
print(“Stack Overflow”)
return

Step-2: top ++
Step-3: arr[top] = data

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Algorithm for POP()

• Algorithm POP(arr, top, data)

Step-1 Check for Underflow,


if (top == -1):
print(“Stack Underflow”)
return

Step-2: data = arr[top]


Step-3: top - -
Step-4: return data

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Algorithm for PEEK()

• Algorithm PEEK(arr, top, data)

Step-1 Check for Underflow,


if (top == -1):
print(“Stack Underflow”)
return

Step-2: data = arr[top]


Step-3: return data

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Applications of Stack :

1. To check Palindrome String: Stack can be used to check whether a string is palindrome or
not. We just have to PUSH all the elements of the string (lets say S) into the stack one by one
and then we will take an empty string (lets say S1) and start adding character into S1 from
stack by popping them. If both the strings S and S1 are equal then it is said to be a Palindrome
String.

2. Balancing of Parenthesis: Stack can be used to check whether brackets(parenthesis) are


balanced in a program or not, When any opening bracket comes it is Pushed into the stack
and when any closing bracket comes the topmost bracket from the stack is Poped at the last
if the stack is empty then Parenthesis is Balanced.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Applications of Stack :

3. Function Call: All the function calls in a program are managed by stack
that is the whole control mechanism is dependent on stack whenever any
function is called it is always pushed into the stack

4. Evaluation of Postfix Expression


Stack is used to evaluate postfix expressions. First we scan the postfix expression
from left to right, If any operand comes it is pushed into the stack and if any operator
comes, 2 elements from the stack are popped and opeartion is performed between
them and result is stored back into stack. When whole expression get completed,
final value from the stack is popped which is the result of expression.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Expressions

Expressions are of three types:

Prefix (Polish notations) - First operator comes and then the left operand
and then right operand

Infix - First left operand then operator then right operand

Postfix (Reverse Polish notations)- First left operand then right operand then
operator

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Expressions

+ab a+b ab+


Postfix
Prefix Infix

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Convert into Prefix Expressions

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Convert into Postfix Expressions

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Convert into Prefix Expressions

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Convert into Postfix Expressions

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Convert into Prefix Expressions

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Convert into Postfix Expressions

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
What is Queue ?

Queue is a linear list with restriction that elements will be inserted from one end called Rear
end and deleted from another end called as Front end of the queue.

Queue is based on the principle of FIFO (first in first out).

Real-life Example: Railway ticket counter, Temple queue etc…


Technical Example: Printer, CPU etc…

There are two operations associated with Queue :


1. Enqueue: It is used to insert the element into the queue.
2. Dequeue: It is used to delete the element from the queue.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Algorithm of Enqueue :

Algorithm Enqueue(arr, rear, n, data)

Step-1: Check for Overflow


if (rear == n):
print(“Queue Overflow”)
return
Step-2: arr[rear] = data
Step-3: rear ++

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Algorithm of Dequeue :
Algorithm Dequeue(arr, rear, front, data)

Step-1: Check for Underflow,


if (front == rear):
print(“Queue Underflow”)
return

Step-2: data = arr[front]


Step-3: for i = 0 to rear-2:
arr [i] = arr [ i +1]
Step-4: rear - -
Step-5: return data
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Types of Queue :

There are three types of queue :


1. Simple Queue: Queue is a linear list with restriction that elements will be insert from
one end called Rear end and delete from another end called Front end of the queue.

2. Circular Queue: Circular Queue is a special type of queue in which the last element
connected to the first element forming a ring like structure, it is called as ring buffer.

3. Priority Queue: Priority Queue is a special queue in which each element is associated
with a priority and the element with higher priority is always deleted first. If two
elements have same priority then they will be deleted in FIFO manner

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
What is Linked List ?
Linked list is a collection of nodes in which each node contains two field, one is data field and
another is linked field/address field.

Data field contains the data and link field contains the address of next node.

Linked list has randomly memory allocation so node can be present anywhere in the memory
without any fixed sequence.

The address of the first node is stored in a special pointer generally called Start/Root/Head.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Types of LINKED LIST :

There are Four types of linked list:

1. Singly Linked List.


2. Singly Circular Linked List.
3. Doubly Linked List.
4. Doubly Circular Linked List.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Singly Linked List :

Singly linked list is a collection of data in which each node contain two field,
one is data field and another is linked field/address field.

Data field contains the data and link field contains the address of next node.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Singly Circular Linked List :

In this type of linked list the address field/ link field of last node
contain the address of first node.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Doubly Linked List :

Doubly linked list is a bidirectional linked list, It is a collection of nodes


where each node contains 3 fields, one data field and two link fields (Rlink,
Llink). Data field contains the data, Rlink contains address of the right node
amd Llink contains address of the left node

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Doubly Circular Linked List :

it is a doubly linked list in which the r-link of last node contains the address
of first node and l-link of first node contains the address of the last node.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
What is Tree ?

Tree is the collection of nodes and edges. The topmost node is called as the root
node. Other nodes are called as the child node. The nodes on a same level are called
sibling nodes. And the nodes which do not have any child are called leaf node.

root node

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
Our Family is the
best real life
example of Tree Data
Structure
Real life examples of Tree:
DSA NOTES

1. Organization Hierarchy:
Example: Corporate organizational structures
Tree Application: Nodes represent employees or positions, and edges represent hierarchical
relationships (supervision).
2. Family Trees:
Example: Genealogy charts
Tree Application: Nodes represent family members, and edges represent parent-child
relationships.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
Technical examples of Tree:
DSA NOTES

File Systems:
Application: Representing the hierarchical structure of directories and files in operating systems.
Description: Trees are used to organize files and directories, allowing for efficient navigation and
management.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Types of TREE :

There are six types of Trees :

1. Binary Tree
2. Perfect Binary Tree
3. Strict Binary Tree
4. Complete Binary Tree
5. Binary Search Tree
6. AVL Tree

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
BINARY TREE :

A Tree in which each node can have at most Two child nodes is called
a Binary Tree.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Height/Depth of a binary tree?

The height of the tree is the number of edges in the


Height=2
tree from the root to the deepest/farthest leaf node.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES

Height=3 Height=4

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
PERFECT BINARY TREE :

A Tree is said to be a Perfect Binary Tree if all its levels are


completely fulfilled.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
STRICT BINARY TREE :

A Tree is said to be a Strict Binary Tree if all its nodes have either 2
children or does not have children at all.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
COMPLETE BINARY TREE :

A Tree is said to be a Complete Binary Tree if all its levels are


completely fulfilled (i.e. It is a perfect binary tree) or if the last level is
not fulfilled then the extra nodes must be as left as possible.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
BINARY SEARCH TREE :

A Tree is said to be a Binary Search Tree , if the node with greater


value then root goes to its right subtree and if the node with smaller
value then root node goes to its left subtree.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
AVL TREE :

AVL Tree is a height balancing binary search tree in which the


balancing factor of each node is either (0,1,-1).

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Balancing Factor:

Balancing Factor= Height of left subtree-Height of right subtree

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Graph:

A Graph is a non-linear data structure consisting of vertices and


edges. The vertices are sometimes also referred to as nodes and the
edges are lines or arcs that connect any two nodes in the graph.
More formally a Graph is composed of a set of vertices( V ) and a set
of edges( E ). The graph is denoted by G(V,E)

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Components of a Graph:

Vertices: Vertices are the fundamental units of the graph.


Sometimes, vertices are also known as vertex or nodes. Every
node/vertex can be labeled or unlabelled.
Edges: Edges are drawn or used to connect two nodes of the
graph.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Real life example of Graph:

Social Networks:
Example: Facebook, Twitter, LinkedIn
Graph Application: Nodes represent individuals, and edges represent connections or
friendships between them.

Transportation Systems:
Example: Google Maps, GPS navigation systems
Graph Application: Nodes represent locations (cities, intersections), and edges
represent roads or pathways connecting them.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES
Internet and Computer Networks:
Example: World Wide Web, network infrastructure
Graph Application: Nodes represent web pages or network devices, and edges represent
links or connections between them.
Recommendation Systems:
Example: Netflix, Amazon, Spotify
Graph Application: Nodes represent users and items, and edges represent interactions or
preferences.
Epidemiology:
Example: Spread of diseases, contact tracing
Graph Application: Nodes represent individuals, and edges represent contacts or
interactions that could facilitate the spread of a disease.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
ABOUT SAI CRT : DSA NOTES

Sai Campus Recruitment Training is the best institute in Central India for Campus Placements located
in Indrapuri, Bhopal. CRT stands for Campus Recruitment Training batch. This is a program where we
teach students everything from basics to advance required to get placed in world's top MNC's like
Amazon, TCS, Infosys, SAP, Capgemini, Accenture, Cognizant etc. After joining this batch you don't
have to worry about anything, We cover every single thing required for your smooth selection.
2000+ students are already placed in their dream MNC's.....,
YES! you are next!

Click me to know everything about our course

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
CLICK ON TOPIC TO WATCH OUR VIDEOS FREE
OF COST ON YT :

DBMS DS HTML CSS


RESUME Basic Programming MOTIVATION

CRT Preparation Python CP NUMBER SYSTEM

And many more on YT...


@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
ABOUT GAURAV TIWARI SIR : DSA NOTES
Mr. Gaurav Tiwari, a multi-faceted individual with a diverse range of talents and achievements. Mr. Tiwari is widely recognized as a
prominent programming trainer, aptitude and logical reasoning instructor, and a proficient communicator. As a famous educator and
emerging entrepreneur, he has left an indelible mark in the world of education and business.

Beyond his expertise in training, Mr. Gaurav Tiwari's passion for chess has led him to achieve international recognition as a rated chess
player. He has represented himself in numerous national and international chess events, showcasing his strategic acumen and
dedication to the game.

As a testament to his innovative abilities, Mr. Tiwari led the team "Ingenious," which emerged victorious in the prestigious Smart India
Hackathon 2017, a platform where young minds collaborate to solve real-world challenges through technology.

His outstanding achievements have not gone unnoticed, as he was honored by the Governor of Madhya Pradesh State for securing the
highest number of job offers from top multinational companies. This accolade exemplifies his exceptional skills and dedication in the
corporate realm.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
ABOUT GAURAV TIWARI SIR : DSA NOTES

Apart from his educational pursuits and entrepreneurial ventures, Mr. Gaurav Tiwari shares his experiences and
knowledge with the world as a daily vlogger on his YouTube channel "Gauraverse." Through this platform, he has
inspired and motivated thousands of viewers.

In a groundbreaking move, Mr. Tiwari established "Cryptovilla Cafe," India's first cryptocurrency-based cafe,
demonstrating his forward-thinking approach to business and technology.

Moreover, his passion for coding and love for teaching have driven him to mentor over 10,000 students, making a
lasting impact on the lives and careers of aspiring coders.

Mr. Gaurav Tiwari's remarkable journey and versatile talents make him an extraordinary individual, leaving an
indelible mark in the domains of education, entrepreneurship, chess, and technology.

@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,


@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.
DSA NOTES

THANK
YOU
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy