Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures & Algorithms in Python 🐍

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.


📂 Project Structure

The repository is organized into core categories based on the nature of the data structure or the algorithmic approach:

1. Searching Algorithms

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.

2. Tree Data Structures

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.

3. Practical Problem Solving

A curated list of classic algorithmic challenges and LeetCode problems:

Array & Binary Search Variations

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 $\sqrt{n}$ using binary search. -
Count 1s Efficiently counting occurrences in a sorted binary array. -

Advanced Tree Properties

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

📈 Complexity Analysis

Algorithm Best Case Average Case Worst Case Space Complexity
Binary Search $O(1)$ $O(\log n)$ $O(\log n)$ $O(1)$
Linear Search $O(1)$ $O(n)$ $O(n)$ $O(1)$
Tree Traversal $O(n)$ $O(n)$ $O(n)$ $O(h)$

🚀 Getting Started

Prerequisites

  • Python 3.10+

Installation

  1. Clone the repository:
    git clone https://github.com/abdoulrahmanebande/Data-Structures-Algorithms-in-Python.git
    
  2. Navigate to the directory:
    cd Data-Structure-Algorithms-Python
    

💻 Usage

Each script is self-contained with example test cases. To run a specific solution, use:

  1. Example: Running the Binary Search implementation
    python algorithms/binary-search/code.py
    
  2. Example: Running the Binary Tree max depth solution
    python problem-for-practice/max_depth_bt.py  
    

🛠️ Roadmap

[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)


🤝 Contributing

Contributions are welcome! If you have a more optimized solution or want to add a new algorithm:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/NewAlgorithm)
  3. Commit your Changes (git commit -m 'Add some NewAlgorithm')
  4. Push to the Branch (git push origin feature/NewAlgorithm)
  5. Open a Pull Request

📜 License

Distributed under the MIT License. See LICENSE for more information.


✉️ Contact

Your Name - [abdoulrahmanebande@gmail.com]

Project Link: https://github.com/abdoulrahmanebande/Data-Structures-Algorithms-in-Python.git

About

This repository covers most of the algorithms and data structures and some practical solved problems and it is implemented in Python in a detailed fashion which makes it easy for beginner to grasp the concept easily.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages