Rauf Khan DSA Notes
Rauf Khan DSA Notes
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.
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.