This repository contains Python implementations of various time complexity examples, helping you understand how different algorithms perform as input size increases.
- Using
time.time()to measure execution time. - Why it's not reliable due to varying machine specs.
- Countdown using
whileloop. - Factorial function O(n) complexity (Iterative vs Recursive).
- Understanding how integers are converted to strings manually.
- O(n²) complexity: Generating pairs in a list.
- O(n × m) complexity: Comparing two lists element-wise.
- Understanding how O(n³) complexity arises.
- Optimized O(n) approach to reverse a list in-place.
- O(2ⁿ) complexity: Why recursive Fibonacci is inefficient.
- Understanding resizing strategy and amortized time complexity.
- How dynamic arrays achieve O(1) average-time complexity for
append(). - Implementing a custom dynamic array in Python.
| Algorithm | Time Complexity |
|---|---|
| Iterative Factorial | O(n) |
| Recursive Factorial | O(n) |
| Nested Loops (Pairs) | O(n²) |
| Comparing Two Lists | O(n × m) |
| Triple Nested Loops | O(n³) |
| List Reversal | O(n) |
| Recursive Fibonacci | O(2ⁿ) (Exponential) |
| Dynamic Array Append | O(1) (Amortized) |
- Clone the repository:
git clone https://github.com/kamalaly611/DSA-TimeCompleixty.git
- Navigate to the folder:
cd DynamicArrays.py - Run the Python file:
python filename.py
- Helps optimize algorithms for large inputs.
- Determines scalability of a solution.
- Avoids inefficiencies in real-world applications.
Want to contribute? Feel free to fork, star ⭐, or open an issue!
📩 Author: kamalaly611
Happy Coding! 🚀