https://github.com/saadsalmanakram/ds-bigo-complexity
It's all about Data Structures... This repository is designed to provide a comprehensive guide to understanding, implementing, and mastering data structures from the ground up.
https://github.com/saadsalmanakram/ds-bigo-complexity
bigonotation data-structures datastructures datastructures-algorithms timecomplexity
Last synced: 6 months ago
JSON representation
It's all about Data Structures... This repository is designed to provide a comprehensive guide to understanding, implementing, and mastering data structures from the ground up.
- Host: GitHub
- URL: https://github.com/saadsalmanakram/ds-bigo-complexity
- Owner: saadsalmanakram
- Created: 2024-08-30T06:23:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-05T14:41:19.000Z (6 months ago)
- Last Synced: 2025-04-05T15:30:46.315Z (6 months ago)
- Topics: bigonotation, data-structures, datastructures, datastructures-algorithms, timecomplexity
- Homepage:
- Size: 94.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# π DS-BigO-Complexity

## π Introduction
**DS-BigO-Complexity** is a comprehensive guide to understanding **Data Structures, Algorithms, and Time Complexity**. This repository is designed for beginners and intermediate learners who want to strengthen their problem-solving skills and optimize their code for efficiency.
πΉ Learn about common **data structures** like arrays, linked lists, trees, graphs, and heaps.
πΉ Implement and analyze **sorting and searching algorithms**.
πΉ Master **Big-O Notation** and understand **time & space complexity**.
πΉ Solve real-world **coding problems** with optimized solutions.---
## π Features
- **In-depth explanations** of fundamental data structures
- **Hands-on implementations** in Python
- **Big-O Complexity Analysis** for each algorithm
- **Visual representations** of sorting & searching algorithms
- **Interview-style problems** with optimal solutions
- **Practice problems & challenges**---
## π Prerequisites
Before getting started, ensure you have:
- **Python 3.x** installed β [Download Here](https://www.python.org/downloads/)
- Basic knowledge of programming concepts---
## π Repository Structure
```
DS-BigO-Complexity/
βββ data_structures/ # Implementations of stacks, queues, linked lists, trees, etc.
βββ algorithms/ # Sorting, searching, dynamic programming, graph algorithms
βββ complexity_analysis/ # Big-O notation, best-case, worst-case, average-case analysis
βββ interview_questions/ # Common DSA questions from tech interviews
βββ visualizations/ # Graphical representations of sorting & searching algorithms
βββ README.md # Project documentation
βββ requirements.txt # Python dependencies
```---
## β³ Understanding Big-O Notation
Big-O notation is used to classify algorithms according to their **runtime complexity**. Hereβs a quick reference:
| Complexity | Name | Example |
|------------|-----------------|--------------------------------|
| O(1) | Constant Time | Accessing an array index |
| O(log n) | Logarithmic Time | Binary search |
| O(n) | Linear Time | Iterating through an array |
| O(n log n) | Linearithmic Time | Merge Sort, Quick Sort |
| O(nΒ²) | Quadratic Time | Nested loops (e.g., Bubble Sort) |
| O(2βΏ) | Exponential Time | Fibonacci recursion |
| O(n!) | Factorial Time | Traveling Salesman Problem |---
## π οΈ Example: Implementing a Sorting Algorithm
Hereβs an implementation of **Merge Sort**, an O(n log n) sorting algorithm:
```python
def merge_sort(arr):
if len(arr) <= 1:
return arr
mid = len(arr) // 2
left_half = merge_sort(arr[:mid])
right_half = merge_sort(arr[mid:])
return merge(left_half, right_half)def merge(left, right):
sorted_arr = []
i = j = 0
while i < len(left) and j < len(right):
if left[i] < right[j]:
sorted_arr.append(left[i])
i += 1
else:
sorted_arr.append(right[j])
j += 1
sorted_arr.extend(left[i:])
sorted_arr.extend(right[j:])
return sorted_arr# Example Usage
arr = [5, 3, 8, 6, 2, 7, 4, 1]
print("Sorted Array:", merge_sort(arr))
```Output:
```
Sorted Array: [1, 2, 3, 4, 5, 6, 7, 8]
```---
## π Topics Covered
### π **Data Structures**
- **Arrays & Strings**
- **Linked Lists** (Singly, Doubly, Circular)
- **Stacks & Queues**
- **Hash Tables & Hash Functions**
- **Trees & Binary Search Trees (BSTs)**
- **Heaps & Priority Queues**
- **Graphs (Adjacency List & Matrix)**### π’ **Algorithms**
- **Sorting Algorithms:** Bubble, Selection, Insertion, Merge, Quick, Heap Sort
- **Searching Algorithms:** Linear Search, Binary Search
- **Graph Algorithms:** BFS, DFS, Dijkstraβs Algorithm
- **Dynamic Programming:** Fibonacci, Knapsack Problem
- **Divide & Conquer:** Merge Sort, Quick Sort
- **Greedy Algorithms:** Huffman Coding, Activity Selection
- **Backtracking:** N-Queens, Sudoku Solver---
## π Problem-Solving Challenges
π The repository includes **real-world problems** with optimal solutions. Examples:
1οΈβ£ Find the **two numbers** in an array that sum up to a target (`O(n)`)
2οΈβ£ Detect a **cycle** in a linked list (`O(n)`)
3οΈβ£ Find the **lowest common ancestor (LCA)** in a BST (`O(log n)`)
4οΈβ£ Implement a **LRU Cache** using a HashMap & Doubly Linked List (`O(1)`)
5οΈβ£ Solve the **N-Queens problem** using Backtracking (`O(N!)`)---
## π₯ Sorting Algorithm Visualizations
The repository includes **sorting visualizations** for algorithms like:
| Algorithm | Time Complexity | Visualization |
|-----------|----------------|---------------|
| Bubble Sort | O(nΒ²) |  |
| Merge Sort | O(n log n) |  |
| Quick Sort | O(n log n) |  |---
## β‘ How to Run the Code
### 1οΈβ£ Clone the Repository
```bash
git clone https://github.com/saadsalmanakram/DS-BigO-Complexity.git
cd DS-BigO-Complexity
```### 2οΈβ£ Install Dependencies
```bash
pip install -r requirements.txt
```### 3οΈβ£ Run Example Scripts
```bash
python algorithms/merge_sort.py
python data_structures/linked_list.py
```---
## π Contributing
Contributions are welcome! π
πΉ **Fork** the repository
πΉ Create a new branch (`git checkout -b feature-name`)
πΉ Commit changes (`git commit -m "Added new sorting algorithm"`)
πΉ Push to your branch (`git push origin feature-name`)
πΉ Open a pull request---
## π License
This project is licensed under the **MIT License** β feel free to use, modify, and share the code.
---
## π Resources & References
- [Big-O Complexity Cheat Sheet](https://www.bigocheatsheet.com/)
- [MIT Algorithms Course](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/)
- [CLRS: Introduction to Algorithms](https://en.wikipedia.org/wiki/Introduction_to_Algorithms)---
## π¬ Contact
For queries or collaboration, reach out via:
π§ **Email:** saadsalmanakram1@gmail.com
π **GitHub:** [SaadSalmanAkram](https://github.com/saadsalmanakram)
πΌ **LinkedIn:** [Saad Salman Akram](https://www.linkedin.com/in/saadsalmanakram/)---
β‘ **Master Data Structures & Algorithms with Confidence!** β‘
---