A comprehensive collection of fundamental data structures and algorithmic problem-solving techniques implemented in Python. This repository tracks my journey through classic computer science problems and LeetCode challenges.
The repository is organized into core categories based on the nature of the data structure or the algorithmic approach:
Basic to advanced techniques for locating elements within data collections.
-
Linear Search: Simple
$O(n)$ approach checking every element. -
Binary Search: Efficient
$O(\log n)$ searching for sorted datasets.
Focuses on hierarchical data organization and traversal.
- Binary Search Tree (BST): Full implementation of insertion, deletion, and searching.
- Tree Traversals:
- Inorder (Left, Root, Right): LeetCode 94.
- Preorder (Root, Left, Right): LeetCode 144.
- Postorder (Left, Right, Root): LeetCode 145.
A curated list of classic algorithmic challenges and LeetCode problems:
| Problem | Description | Source |
|---|---|---|
| First/Last Position | Find the starting and ending index of a target in a sorted array. | LeetCode 34 |
| Standard Search | Classic binary search implementation. | LeetCode 704 |
| Rotated Sorted List | Finding elements or pivots in cyclically shifted arrays. | - |
| Square Root | Finding the floor of |
- |
| Count 1s | Efficiently counting occurrences in a sorted binary array. | - |
| Problem | Description | Source |
|---|---|---|
| Maximum Depth | Longest path from root to leaf node. | LeetCode 104 |
| Minimum Depth | Shortest path to the nearest leaf node. | LeetCode 111 |
| Diameter | Length of the longest path between any two nodes. | LeetCode 543 |
| Completeness | Determining if a tree is a "Complete Binary Tree". | LeetCode 958 |
| Algorithm | Best Case | Average Case | Worst Case | Space Complexity |
|---|---|---|---|---|
| Binary Search | ||||
| Linear Search | ||||
| Tree Traversal |
- Python 3.10+
- Clone the repository:
git clone https://github.com/abdoulrahmanebande/Data-Structures-Algorithms-in-Python.git
- Navigate to the directory:
cd Data-Structure-Algorithms-Python
Each script is self-contained with example test cases. To run a specific solution, use:
- Example: Running the Binary Search implementation
python algorithms/binary-search/code.py
- Example: Running the Binary Tree max depth solution
python problem-for-practice/max_depth_bt.py
[x] Linear Search and Binary Search & Practices Implementations
[x] Binary Search Trees, Traversals and Recursion & Practices Implementations
[ ] Linked List Implementations (Singly & Doubly)
[ ] Sorting Algorithms (Merge Sort, Quick Sort)
[ ] Dynamic Programming Challenges
[ ] Graph Algorithms (BFS, DFS)
Contributions are welcome! If you have a more optimized solution or want to add a new algorithm:
- Fork the Project
- Create your Feature Branch (git checkout -b feature/NewAlgorithm)
- Commit your Changes (git commit -m 'Add some NewAlgorithm')
- Push to the Branch (git push origin feature/NewAlgorithm)
- Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Your Name - [abdoulrahmanebande@gmail.com]
Project Link: https://github.com/abdoulrahmanebande/Data-Structures-Algorithms-in-Python.git