DATA STRUCTURES NOTES - AKTU + FUTURE PREPARATION
-----------------------------------------
UNIT 1: INTRODUCTION TO DATA STRUCTURES
-----------------------------------------
Definition:
A Data Structure (DS) is a way of organizing and storing data so that it can be accessed and
modified efficiently.
Types of Data Structures:
1. Primitive: int, char, float, double
2. Non-Primitive:
- Linear: Array, Linked List, Stack, Queue
- Non-Linear: Tree, Graph
Operations: Traversing, Insertion, Deletion, Searching, Sorting, Merging
Importance:
- Improves algorithm efficiency
- Memory optimization
- Crucial for competitive programming, AI, ML, and DBMS.
-----------------------------------------
UNIT 2: ARRAYS AND LINKED LISTS
-----------------------------------------
Array:
- Collection of elements of same data type in contiguous memory.
- Fast access (O(1)), but fixed size.
Operations: Traversal, Insertion, Deletion, Searching.
Linked List:
- Nodes connected via pointers.
Types: Singly, Doubly, Circular.
Pros: Dynamic memory allocation.
Cons: No random access, extra pointer memory.
Applications: Playlists, Memory management, Undo/Redo.
-----------------------------------------
UNIT 3: STACKS AND QUEUES
-----------------------------------------
Stack (LIFO):
Operations: Push, Pop, Peek
Applications: Recursion, Expression evaluation, Undo feature.
Queue (FIFO):
Operations: Enqueue, Dequeue
Types: Simple, Circular, Priority, Deque.
Applications: CPU scheduling, printer queues, process management.
-----------------------------------------
UNIT 4: TREES
-----------------------------------------
Tree: Hierarchical data structure with root and child nodes.
Binary Tree: Each node has at most 2 children.
Traversal:
- Inorder (LNR), Preorder (NLR), Postorder (LRN), Level Order.
Binary Search Tree (BST):
Left < Root < Right
Applications: Searching, indexing, sorting.
Other Trees: AVL Tree, Heap Tree, B-Tree, B+ Tree.
-----------------------------------------
UNIT 5: GRAPHS
-----------------------------------------
Definition: Set of vertices (V) and edges (E).
Types: Directed/Undirected, Weighted/Unweighted.
Representations: Adjacency Matrix, Adjacency List.
Traversal: BFS (Queue), DFS (Stack/Recursion)
Applications: Maps, Social Networks, Path finding (Dijkstra).
-----------------------------------------
UNIT 6: SORTING AND SEARCHING
-----------------------------------------
Sorting Algorithms:
Bubble, Insertion, Selection, Merge, Quick, Heap.
Complexities:
- Bubble/Insertion: O(n^2)
- Merge/Quick: O(n log n)
Searching:
Linear: O(n)
Binary: O(log n) - requires sorted array.
-----------------------------------------
UNIT 7: HASHING AND FILE STRUCTURE
-----------------------------------------
Hashing:
Maps keys to values using a hash function.
Collision Handling: Chaining, Linear/Quadratic Probing, Double Hashing.
File Structures:
Sequential, Indexed, Direct Access.
-----------------------------------------
COMMON AKTU QUESTIONS (7 MARKS)
-----------------------------------------
1. Types of data structures.
2. Arrays vs Linked Lists.
3. Stack & Queue operations.
4. Tree traversals.
5. DFS vs BFS.
6. Quick Sort / Merge Sort.
7. Hashing and collision resolution.
-----------------------------------------
FUTURE PREPARATION (DSA INTERVIEWS)
-----------------------------------------
Key Topics to Practice:
- Arrays: Two Sum, Kadane's Algorithm
- Linked List: Reverse, Detect Cycle
- Stack: Valid Parentheses
- Queue: Implement Queue using Stacks
- Trees: LCA, Level Order Traversal
- Graph: BFS, DFS, Dijkstra
- Sorting: Merge, Quick Sort
- Searching: Binary Search variations
Focus on:
- Time & Space Complexity (Big O)
- Problem-solving & implementation on LeetCode/GFG.