Introduction To DSA
Introduction To DSA
Topperworld.in
Trees and Graphs are widely used non-linear data structures. Tree and
graph structures represents hierarchial relationship between individual data
elements. Graphs are nothing but trees with certain restrictions removed.
Due to the complexity of applications and the daily growth in data, there
may be issues with processing speed, data searching, handling
numerous requests, etc. Data structure offers a method for effectively
managing, organising, and storing data. Data structures make it simple
to navigate through the data elements. Data structures offer productivity,
reuse, and abstraction. Because storing and retrieving user data as
quickly as feasible is a program's primary job, it plays a significant role in
improving performance.
©Topperworld
Data Structure and Algorithms
Data Structures
©Topperworld
Data Structure and Algorithms
In stack data structure, elements are stored in the LIFO principle. That is,
the last element stored in a stack will be removed first.
It works just like a pile of plates where the last plate kept on the pile will
be removed first.
©Topperworld
Data Structure and Algorithms
In a stack, operations can be perform only from one end (top here).
Unlike stack, the queue data structure works in the FIFO principle where
first element stored in the queue will be removed first.
It works just like a queue of people in the ticket counter where first
person on the queue will get the ticket first.
In linked list data structure, data elements are connected through a series
of nodes. And, each node contains the data items and address to the next
node.
©Topperworld
Data Structure and Algorithms
A linked list
Unlike linear data structures, elements in non-linear data structures are not
in any sequence. Instead they are arranged in a hierarchical manner where
one element will be connected to one or more elements.
Non-linear data structures are further divided into graph and tree based
data structures.
In graph data structure, each node is called vertex and each vertex is
connected to other vertices through edges.
©Topperworld
Data Structure and Algorithms
Now that we know about linear and non-linear data structures, let's see
the major differences between them.
• The data items are arranged in The data items are arranged in
sequential order, one after the non-sequential order
other. (hierarchical manner).
• All the items are present on the The data items are present at
single layer. different layers.
©Topperworld
Data Structure and Algorithms
The collection of data you work with in a program have some kind of
structure or organization. No matter how complex your data structures are
they can be broken down into two fundamental types:
• Contiguous
• Non-Contiguous
➔Contiguous Structures
➔Non-Contiguous Structures
©Topperworld
Data Structure and Algorithms
1 2 3 1 2 2
(a) Non-Contiguous (b) Non-Contiguous
➔Hybrid structures
If two basic types of structures are mixed then it is a hybrid form. Then one
part contiguous and another part non-contiguous.
D P N
1 A 3 4
2 B
A 4 0
(b) Hybrid Structure
3 C 0 1
4 D 1 2
List Head
©Topperworld
Data Structure and Algorithms
The array D contains the data for the list, whereas the array P and N hold
the previous and next “pointers’’. The pointers are actually nothing more
than indexes into the D array. For instance, D[i] holds the data for node i
and p[i] holds the index to the node previous to i, where may or may not
reside at position i–1. Like wise, N[i] holds the index to the next node in
the list.
Data structure operations are the methods used to manipulate the data in
a data structure. The most common data structure operations are:
©Topperworld
Data Structure and Algorithms
➔ Data Storage:
➔ Data Exchange:
Data structures such as linked lists can enable core operating systems
resources and services to perform functions like file directory management,
memory allocation, and processing scheduling queues.
➔ Scalability:
Big data applications rely on data structures to manage and allocate data
storage across many distributed storage locations. This function guarantees
scalability and high performance.
©Topperworld
Data Structure and Algorithms
• The data structure allows for the effective and efficient processing of
both little and big amounts of data.
• Data structures such as arrays, trees, linked lists, stacks, graphs, and
so on are thoroughly verified and proved, so anybody may use them
directly without the need for study and development. If you opt to
design your own data structure, you may need to do some study, but
it will almost certainly be to answer a problem that is more
sophisticated than what these can supply.
©Topperworld