0% found this document useful (0 votes)
17 views

Rauf Khan DSA Notes

Uploaded by

Abdul rauf Khan
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)
17 views

Rauf Khan DSA Notes

Uploaded by

Abdul rauf Khan
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/ 6

Data Structures and Algorithms (DSA) refer to the study of methods for

organizing and storing data and the design of procedures (algorithms) for
solving problems, which operate on these data structures. DSA is one of the
most important skills that every computer science student must have. It is often
seen that people with good knowledge of these technologies are better
programmers than others and thus, crack the interviews of almost every tech
giant. This DSA tutorial aims to help you learn Data Structures and Algorithms
(DSA) quickly and easily.

Common Data Structures to learn:


1. Array
Array is a linear data structure that stores a collection of elements of the
same data type. Elements are allocated contiguous memory, allowing for
constant-time access. Each element has a unique index number.
• Operations on Array:
• Traversal: Iterating through the elements of an array.
• Insertion: Adding an element to the array at a specific index.
• Deletion: Removing an element from the array at a specific
index.
• Searching: Finding an element in the array by its value or index.
• Types of Arrays:
• One-dimensional array: A simple array with a single dimension.
• Multidimensional array: An array with multiple dimensions,
such as a matrix.
• Applications of Array:
• Storing data in a sequential manner
• Implementing queues, stacks, and other data structures
• Representing matrices and tables
Linked List Data Structure

A linked list is a fundamental data structure in computer science. It consists of
nodes where each node contains data and a reference (link) to the next node in
the sequence. This allows for dynamic memory allocation and
efficient insertion and deletion operations compared to arrays.

Common Data Structures to learn:


1. Array
Array is a linear data structure that stores a collection of elements of the
same data type. Elements are allocated contiguous memory, allowing for
constant-time access. Each element has a unique index number.
• Operations on Array:
• Traversal: Iterating through the elements of an array.
• Insertion: Adding an element to the array at a specific index.
• Deletion: Removing an element from the array at a specific
index.
• Searching: Finding an element in the array by its value or index.
• Types of Arrays:
• One-dimensional array: A simple array with a single dimension.
• Multidimensional array: An array with multiple dimensions,
such as a matrix.
• Applications of Array:
• Storing data in a sequential manner
• Implementing queues, stacks, and other data structures
• Representing matrices and tables
Stack Data Structure

A Stack is a linear data structure that follows a particular order in which the
operations are performed. The order may be LIFO(Last In First
Out) or FILO(First In Last Out). LIFO implies that the element that is inserted
last, comes out first and FILO implies that the element that is inserted first,
comes out last.
Key Operations on Stack Data Structures
• Push: Adds an element to the top of the stack.
• Pop: Removes the top element from the stack.
• Peek: Returns the top element without removing it.
• IsEmpty: Checks if the stack is empty.
• IsFull: Checks if the stack is full (in case of fixed-size arrays).
Applications of Stack Data Structures
• Recursion
• Expression Evaluation and Parsing
• Depth-First Search (DFS)
• Undo/Redo Operations
• Browser History
• Function Calls

6. Queue
A Queue Data Structure is a fundamental concept in computer science used for
storing and managing data in a specific order. It follows the principle of “First in,
First out” (FIFO), where the first element added to the queue is the first one to be
removed
• Operation on Queue:
• Enqueue: Adds an element to the rear of the queue
• Dequeue: Removes an element from the front of the queue
• Peek: Retrieves the front element without removing it
• IsEmpty: Checks if the queue is empty
• IsFull: Checks if the queue is full
• Type of Queue:
• Circular Queue: Last element connects to the first element
• Double-Ended Queue (Deque): Operations can be performed
from both ends
• Priority Queue: Elements are arranged based on priority
• Applications of Queue:
• Job scheduling
• Message queuing
• Simulation modeling
• Data buffering
7. Heap
A Heap is a complete binary tree data structure that satisfies the heap
property: for every node, the value of its children is less than or equal to its
own value. Heaps are usually used to implement priority queues, where the
smallest (or largest) element is always at the root of the tree.
• Operations of Heap:
• Insert: Adds a new element to the heap while maintaining heap
properties.
• Extract-Max/Extract-Min: Removes the root element and
restructures the heap.
• Increase/Decrease-Key: Updates the value of a node and
restructures the heap.
• Types of Heap:
• Max-Heap: Root node has the maximum value among its
children.
• Min-Heap: Root node has the minimum value among its children.
• Applications of Heap:
• Priority queues
• Sorting
• Graph algorithms (e.g., Dijkstra’s algorithm)
• Related posts:
• Heap Tutorial
• Top 50 Problems on Heap for Interviews
• Practice Problems on Heap

8. Hash
Hashing is a technique that generates a fixed-size output (hash value) from
an input of variable size using mathematical formulas called hash functions.
Hashing is used to determine an index or location for storing an item in a
data structure, allowing for efficient retrieval and insertion.
9. Tree
A tree is a non-linear hierarchical data structure consisting of nodes connected by
edges, with a top node called the root and nodes having child nodes. It is used in
computer science for organizing data efficiently.
• Traversal of Tree: Tree traversal methods are used to visit and
process nodes in a tree data structure. The three common traversal
methods are:
• In-Order: Visit left subtree, current node, then right subtree.
• Pre-Order: Visit current node, left subtree, then right subtree.
• Post-Order: Visit left subtree, right subtree, then current node.

You might also like