DSA Unit I - Brief Notes
1. Data Structures
Definition: Organized way to store and manage data.
Classification:
- Linear: Arrays, Linked Lists, Stacks, Queues
- Non-linear: Trees, Graphs
Operations: Insertion, Deletion, Traversal, Searching, Sorting.
2. Abstract Data Type (ADT)
Logical description of data and its operations, not implementation.
Example: Stack - push, pop operations.
3. Algorithm Basics
Preliminaries: Steps to solve problems logically.
Time Complexity: Measures runtime (e.g., O(n), O(log n)).
Space Complexity: Memory usage of an algorithm.
4. Searching Algorithms
Linear Search: Check each item. Time: O(n)
Binary Search: For sorted data. Divide in half. Time: O(log n)
Fibonacci Search: Uses Fibonacci sequence for dividing.
5. Sorting Algorithms
Insertion Sort: Insert element in sorted part. Time: O(n²)
Selection Sort: Select min element each time. Time: O(n²)
Bubble Sort: Swap adjacent if out of order. Time: O(n²)
Quick Sort: Use pivot, divide & sort. Best: O(n log n)
Radix Sort: Sort by digit position. Time: O(nk)
Merge Sort: Divide and merge. Time: O(n log n)