LexGlu / algorithms-ds

Implementation of algorithms and data structures in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Algorithms and Data Structures

Practice for implementing algorithms and data structures in Python.

Algorithms

Sorting

  1. Bubble Sort
  • Worst-case time complexity: O(n^2)
  • Best-case time complexity: O(n)
  • Average-case time complexity: O(n^2)
  • Worst space complexity: O(1)
  • bubble-sort
  1. Reverse Bubble Sort
  • The same as bubble sort, but traverses the list in reverse order and moves the smallest element to the start of the list.
  1. Shaker (Cocktail) Sort
  • Bidirectional bubble sort, that performs a bubble sort in both directions
  • Performs better than bubble sort, but still has the same worst-case time complexity
  • Worst-case time complexity: O(n^2)
  • Best-case time complexity: O(n)
  • Average-case time complexity: O(n^2)
  • Worst space complexity: O(1)
  • shaker-sort
  1. Insertion Sort
  • Worst-case time complexity: O(n^2)
  • Best-case time complexity: O(n)
  • Average-case time complexity: O(n^2)
  • Worst space complexity: O(1)
  • insertion-sort
  1. Selection Sort
  • Worst-case time complexity: O(n^2)
  • Best-case time complexity: O(n^2)
  • Average-case time complexity: O(n^2)
  • Worst space complexity: O(1)
  • selection-sort
  1. Merge Sort
  • Worst-case time complexity: O(nlogn)
  • Best-case time complexity: O(nlogn)
  • Average-case time complexity: O(nlogn)
  • Worst space complexity: O(n)
  • merge-sort
  1. Quick Sort
  • Worst-case time complexity: O(n^2)
  • Best-case time complexity: O(nlogn)
  • Average-case time complexity: O(nlogn)
  • Worst space complexity: O(logn)
  • quick-sort

Setup

  1. Clone the repository with git clone https://github.com/LexGlu/algorithms-ds.git
  2. Navigate to the root directory of the project with cd algorithms-ds
  3. Create a virtual environment with python -m venv venv
  4. Activate the virtual environment with source venv/bin/activate
  5. Install the dependencies with pip install -r requirements.txt

Testing

Pytest is used for automated testing of each algorithm. To run the tests, run pytest in the root directory of the project.

About

Implementation of algorithms and data structures in Python


Languages

Language:Python 100.0%