Data Structures Study Material
Data Structures Study Material
STUDY MATERIAL
Data Structure is a particular way of storing and organizing data in a computer’s memory
so that the data can be efficiently accessed.
for(i=0;i<n;i++)
{
print(“Sai Campus Recruitment Training”)
}
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”)
}
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”)
}
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”)
}
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”)
}
}
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)
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)
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 ?
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 .
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 .
Step-2: top ++
Step-3: arr[top] = data
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.
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
Prefix (Polish notations) - First operator comes and then the left operand
and then right operand
Postfix (Reverse Polish notations)- First left operand then right operand then
operator
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.
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
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.
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.
In this type of linked list the address field/ link field of last node
contain the address of first node.
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.
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
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.
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.
1. Binary Tree
2. Perfect Binary Tree
3. Strict Binary Tree
4. Complete Binary Tree
5. Binary Search Tree
6. AVL Tree
A Tree in which each node can have at most Two child nodes is called
a Binary Tree.
Height=3 Height=4
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.
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.
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!
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.
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.
THANK
YOU
@gaurav._.tiwari_ Gauraverse 2nd floor, above Apoorti Mall,
@saicampustraining Sai Campus Recruitment Training Sector C, Indrapuri, Bhopal.