Minimal examples of data structures and algorithms in Python

Overview

PyPI version Open Source Helpers Build Status Coverage Status

Pythonic Data Structures and Algorithms

Minimal and clean example implementations of data structures and algorithms in Python 3.

Contributing

Thanks for your interest in contributing! There are many ways to contribute to this project. Get started here

Tests

Use unittest

For running all tests write down:

$ python3 -m unittest discover tests

For running some specific tests you can do this as following (Ex: sort):

$ python3 -m unittest tests.test_sort

Use pytest

For running all tests write down:

$ python3 -m pytest tests

Install

If you want to use the API algorithms in your code, it is as simple as:

$ pip3 install algorithms

You can test by creating a python file: (Ex: use merge_sort in sort)

from algorithms.sort import merge_sort

if __name__ == "__main__":
    my_list = [1, 8, 3, 5, 6]
    my_list = merge_sort(my_list)
    print(my_list)

Uninstall

If you want to uninstall algorithms, it is as simple as:

$ pip3 uninstall -y algorithms

List of Implementations

Contributors

Thanks to all the contributors who helped in building the repo.

Comments
  • Implement bst tree

    Implement bst tree

    Hi, I implement the bst tree. insert, and search works now. But I am not sure why size method does not work: The error: AttributeError: 'NoneType' object has no attribute 'size' @goswami-rahul @christianbender Could you help me?

    opened by danghai 16
  • Plan for testing

    Plan for testing

    I want to add some additional matrix algorithms and some tests for that.

    So, do you have a testing plan of test format, rules of in/output example data, test script name and others?

    enhancement 
    opened by mingrammer 16
  • Logo/Icon

    Logo/Icon

    Greetings, Im a graphics designer here on Github and I would like to ask for your permission to design for your logo/icon that you maybe used for your future plans in your project. I want to help open source projects by designing logos or banners for there project. Thank you for your time reading this

    Best regards -jbeguna04

    opened by jbeguna04 15
  • added nearest neighbor algorithm - machine-learning

    added nearest neighbor algorithm - machine-learning

    • Two functions nearest_neighbor(x, tSet) and a (eulidean) distance function distance(x,y).
    • I used the numpy library for calculating the absolute value of a vector.
    • Two trainings sets for the logical AND-function and for color-analysing (dark/light color).

    Have someone a tip for finding the k-nearest neighbors? I wrote a simple algorithm.

    • [X] If creating a new file :

      • [X] added links to it in the README files ?
      • [X] included tests with it ?
      • [ ] added description (overview of algorithm, time and space compleixty, and possible edge case) in docstrings ?
    • [ ] if done some changes :

      • [ ] wrote short description in the PR explaining what the changes do ?
      • [ ] Fixes #[issue number] if related to any issue
    • [] other

    opened by christianbender 14
  • separate test module

    separate test module

    Since we now have tests in most of the algorithms, I think it is a good idea to have a separate test_module.py file in each module. We can move all the tests from one module to it, and any further algorithms must have their tests in this file. It will make the repo easy to manage. @keon what do you think? I can start working on this.

    help wanted for newcomers 
    opened by goswami-rahul 11
  • WIP: Fix some issues in Travis and add more python env

    WIP: Fix some issues in Travis and add more python env

    This PR does some tasks:

    • [x] : Add requirements dependency in requirements.txt for algorithms.

    • [x] : Update cache, and coverall ( algorithms and tests) in Travis

    • [x] : Switch to use tox for running the unittest, coveralls. Add more python environment for testing. It does not only test for python 3.6. It could probably test python 3.4, 3.5, 3.6

    opened by danghai 10
  • Fix sort

    Fix sort

    I added doc sting to wiggle_sort.py, modified counting_sort.py and merge_sort.py so that the type of returned array is also numpy.ndarray when the type of input array is numpy.ndarray (the other sort method already achieved this). I alos wrap function in quick_sort.py, so we can use quick sort just like other sort method. And I also modified all the files according to pep8 specification.

    opened by techkang 10
  • Tests in directory tests

    Tests in directory tests

    tests
    If I ran the tests I get this kind of error message:

    from search.binary_search import binary_search, binary_search_recur ImportError: No module named 'search'

    or

    from array.delete_nth import delete_nth, delete_nth_naive ImportError: No module named 'array.delete_nth'; 'array' is not a package

    opened by christianbender 9
  • Adding k_factor.py in dp folder in add_K_FactorofStrings branch

    Adding k_factor.py in dp folder in add_K_FactorofStrings branch

    I have implemented an algorithm to solve a dp problem named "K-factor" Problem statement: The K factor of a string is defined as the number of times ‘abba’ appears as a substring. Given two numbers N and k,​ find the number of strings of length N with ‘K factor’ = k.

    opened by TheCodeYoda 8
  • Added fractional knapsack

    Added fractional knapsack

    I have added fractional knapsack code under greedy. Given the weights and values of n items, we need to put these items in a knapsack of capacity W to get the maximum total value in the knapsack. In Fractional Knapsack, we can break items for maximizing the total value of the knapsack.

    hacktoberfest-accepted 
    opened by ritikverma2000 8
  • Organizing the repo neatly

    Organizing the repo neatly

    Hey guys, I was wondering we should put all the algorithms in an algorithm folder or something. I feel like It's getting big with all those new files being added to it. I have to scroll all the way down or up to get to where I want and right now I feel it is a bit disorganized. It would be very easy for readers to just click the algorithm folder and look for the intended algorithms inside it. The extra junk can remain outside. What do you guys think?

    enhancement 
    opened by SaadBenn 8
  • Added 4 more algorithms with test case

    Added 4 more algorithms with test case

    Reference issues/PRs:

    None

    What does this implementation/fix? Explain your changes.

    These are just some algorithm that I found useful.

    algorithms/dp/ 1. Wildcard matching 2. Trapping rain water

    algorithms/graph/ 1. Kadane's algorithm 2. Kahn's algorithm

    Any other comments?

    No

    opened by Yash5675 0
Releases(v0.1.4)
Owner
Keon
Keon
Implementation for Evolution of Strategies for Cooperation

Moraliser Implementation for Evolution of Strategies for Cooperation Dependencies You will need a python3 (= 3.8) environment to run the code. Before

1 Dec 21, 2021
Implementation of an ordered dithering algorithm used in computer graphics

Ordered Dithering Project In this project, we use an ordered dithering method to turn an RGB image, first to a gray scale image and then, turn the gra

1 Oct 26, 2021
Python algorithm to determine the optimal elevation threshold of a GNSS receiver, by using a statistical test known as the Brown-Forsynthe test.

Levene and Brown-Forsynthe: Test for variances Application to Global Navigation Satellite Systems (GNSS) Python algorithm to determine the optimal ele

Nicolas Gachancipa 2 Aug 09, 2022
A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD.

8QueensGenetic A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD. The project uses the Kivy cross-p

Ahmed Gad 16 Nov 13, 2022
The test data, code and detailed description of the AW t-SNE algorithm

AW-t-SNE The test data, code and result of the AW t-SNE algorithm Structure of the folder Datasets: This folder contains two datasets, the MNIST datas

1 Mar 09, 2022
This is a demo for AAD algorithm.

Asynchronous-Anisotropic-Diffusion-Algorithm This is a demo for AAD algorithm. The subroutine of the anisotropic diffusion algorithm is modified from

3 Mar 21, 2022
Minimal examples of data structures and algorithms in Python

Pythonic Data Structures and Algorithms Minimal and clean example implementations of data structures and algorithms in Python 3. Contributing Thanks f

Keon 22k Jan 09, 2023
Silver Trading Algorithm

Silver Trading Algorithm This project was done in the context of the Applied Algorithm Trading Course (FINM 35910) at the University of Chicago. Motiv

Laurent Lanteigne 1 Jan 29, 2022
Code for generating alloy / disordered structures through the special quasirandom structure (SQS) algorithm

Code for generating alloy / disordered structures through the special quasirandom structure (SQS) algorithm

Bruno Focassio 1 Nov 10, 2021
Apriori - An algorithm for frequent item set mining and association rule learning over relational databases

Apriori Apriori is an algorithm for frequent item set mining and association rul

Mohammad Nazari 8 Jan 10, 2022
Python implementation of Aho-Corasick algorithm for string searching

Python implementation of Aho-Corasick algorithm for string searching

Daniel O'Sullivan 1 Dec 31, 2021
Algorithms-in-Python - Programs related to DSA in Python for placement practice

Algorithms-in-Python Programs related to DSA in Python for placement practice CO

MAINAK CHAUDHURI 2 Feb 02, 2022
Algorithmic virtual trading using the neostox platform

Documentation Neostox doesnt have an API Support, so this is a little selenium code to automate strategies How to use Clone this repository and then m

Abhishek Mittal 3 Jul 20, 2022
Algorithmic trading backtest and optimization examples using order book imbalances. (bitcoin, cryptocurrency, bitmex)

Algorithmic trading backtest and optimization examples using order book imbalances. (bitcoin, cryptocurrency, bitmex)

172 Dec 21, 2022
Programming Foundations Algorithms With Python

Programming-Foundations-Algorithms Algorithms purpose to solve a specific proplem with a sequential sets of steps for instance : if you need to add di

omar nafea 1 Nov 01, 2021
My own Unicode compression algorithm

Zee Code ZCode is a custom compression algorithm I originally developed for a competition held for the Spring 2019 Datastructures and Algorithms cours

Vahid Zehtab 2 Oct 20, 2021
An open source algorithm and dataset for finding poop in pictures.

The shitspotter module is where I will be work on the "shitspotter" poop-detection algorithm and dataset. The primary goal of this work is to allow for the creation of a phone app that finds where yo

Jon Crall 29 Nov 29, 2022
This application solves sudoku puzzles using a backtracking recursive algorithm

This application solves sudoku puzzles using a backtracking recursive algorithm. The user interface is coded with Pygame to allow users to easily input puzzles.

Glenda T 0 May 17, 2022
Algorithmic Trading with Python

Source code for Algorithmic Trading with Python (2020) by Chris Conlan

Chris Conlan 1.3k Jan 03, 2023
Leveraging Unique CPS Properties to Design Better Privacy-Enhancing Algorithms

Differential_Privacy_CPS Python implementation of the research paper Leveraging Unique CPS Properties to Design Better Privacy-Enhancing Algorithms Re

Shubhesh Anand 2 Dec 14, 2022