Data Structures & Algorithms
DSA Part-1
- Introduction to Data Structures
- Asymptotic Notations: Big-O, Omega, and Theta Notations
- Time Complexity and Space Complexity Analysis of Algorithms
- 1D Arrays: Memory Representation and Address Calculation
- 2D Arrays: Row-Major and Column-Major Order Formulas and Numericals
- Array Operations: Traversal, Insertion, and Deletion with Algorithms
- Sparse Matrix: Triplet Representation and Linked Representation
- String Operations, Memory Storage, and Pattern Matching Basics
- Linear Search Algorithm and Complexity Analysis
- Binary Search Algorithm (Iterative and Recursive)
- Bubble Sort Algorithm and Optimization
- Selection Sort Algorithm and Step-by-Step Trace
- Insertion Sort Algorithm and In-Place Analysis
- Merge Sort Algorithm (Divide and Conquer Approach)
- Quick Sort Algorithm and Partitioning Methods
- Counting Sort Algorithm (Non-Comparison Sorting)
- Radix Sort Algorithm and Bucket Distribution
DSA Part-2
- Singly Linked List: Concept and Memory Allocation
- Singly Linked List: Insertion Operations
- Singly Linked List: Deletion Operations
- Singly Linked List: Reversal and Search Operations
- Doubly Linked List: Node Structure and Traversal
- Doubly Linked List: Insertion and Deletion Operations
- Circular Singly Linked List: Concept and Operations
- Circular Doubly Linked List: Concept and Operations
- Header Linked List: Grounded and Circular Header Lists
- Polynomial Representation and Addition using Linked List
DSA Part-3
- Stack Data Structure: Array Implementation
- Stack Implementation using Linked List
- Infix, Prefix, and Postfix Notations
- Infix to Postfix Conversion using Stack
- Infix to Prefix Conversion using Stack
- Evaluation of Postfix Expression using Stack
- Recursion and System Stack (Tower of Hanoi)
- Linear Queue: Array Implementation and Operations
- Drawbacks of Linear Queue and Memory Wastage
- Circular Queue: Array Implementation and Condition Checks
- Queue Implementation using Linked List
- Double-Ended Queue (Deque): Input and Output-Restricted
- Priority Queue: Concept, Array and Heap Representation
DSA Part-4
- Tree Data Structure: Terminology and Basic Concepts
- Binary Trees: Types and Properties
- Binary Tree Traversals: Inorder, Preorder, and Postorder
- Level Order Traversal of Binary Tree
- Binary Search Tree (BST): Concept and Search Operation
- Binary Search Tree (BST): Insertion and Deletion Operations
- AVL Tree: Concept and Balance Factor
- AVL Tree Rotations: LL, RR, LR, and RL Rotations
- Binary Heap: Min-Heap and Max-Heap Properties
- Heap Operations: Heapify, Insertion, and Deletion
- B-Tree: Properties, Structure, and Insertion
- B+ Tree: Structure and Comparison with B-Tree
DSA Part-5
- Graph Data Structure: Terminology and Types
- Graph Representation: Adjacency Matrix and Adjacency List
- Breadth First Search (BFS) Algorithm for Graphs
- Depth First Search (DFS) Algorithm for Graphs
- Hashing: Hash Tables and Hash Functions
- Collision Resolution: Open Addressing Techniques
- Collision Resolution: Separate Chaining Method
Merge Sort Algorithm (Divide and Conquer Approach)
Merge Sort ek highly efficient, comparison-based sorting algorithm hai jo Divide and Conquer algorithmic design paradigm par completely based hai. Iska worst-case time complexity guaranteed O(n log n) hota hai.
Divide and Conquer Steps
- Divide: Array ko tab tak recursively do equal halves me divide karte hain jab tak har subarray me sirf 1 element na bache (single element array by default sorted hota hai).
- Conquer: Subarrays ko recursively sort karte hain.
- Combine (Merge): Do already sorted subarrays ko compare karke ek single consolidated sorted array me merge karte hain.
Divide Phase:
[ 38, 27, 43, 3, 9, 82, 10 ]
/ \
[ 38, 27, 43, 3 ] [ 9, 82, 10 ]
/ \ / \
[38, 27] [43, 3] [9, 82] [10]
/ \ / \ / \ |
[38] [27] [43] [3] [9] [82] [10]
Merge Phase:
[27, 38] [3, 43] [9, 82] [10]
\ / \ /
[ 3, 27, 38, 43 ] [ 9, 10, 82 ]
\ /
[ 3, 9, 10, 27, 38, 43, 82 ]
Merge Procedure Algorithm
MERGE(A, low, mid, high)
1. n1 = mid - low + 1, n2 = high - mid
2. Create temp arrays L[n1] and R[n2]
3. Copy data to L and R
4. Initialize i = 0, j = 0, k = low
5. While i < n1 and j < n2 do:
6. If L[i] <= R[j] then:
A[k] = L[i]; i = i + 1
Else:
A[k] = R[j]; j = j + 1
k = k + 1
7. Copy remaining elements of L and R into A
Recurrence Relation and Complexity
Merge sort ki recurrence equation:
T(n) = 2T(n/2) + Θ(n)
Master Theorem (Case 2: a = 2, b = 2, f(n) = n => n^(log2 2) = n) apply karne par:
- Time Complexity:
O(n log n)Best, Average aur Worst tino cases me! - Space Complexity:
O(n)auxiliary space temp arrays ke liye (Merge sort in-place nahi hota). - Stability: Stable sorting algorithm.
Agli post me hum cover karenge Quick Sort Algorithm and Partitioning Methods.