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
Algorithms and data structures for educational, demonstrational and experimental purposes.

Algorithms and Data Structures (ands) Introduction This project was created for personal use mostly while studying for an exam (starting in the month

null 50 Dec 6, 2022
Cormen-Lib - An academic tool for data structures and algorithms courses

The Cormen-lib module is an insular data structures and algorithms library based on the Thomas H. Cormen's Introduction to Algorithms Third Edition. This library was made specifically for administering and grading assignments related to data structure and algorithms in computer science.

Cormen Lib 12 Aug 18, 2022
zoofs is a Python library for performing feature selection using an variety of nature inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics based to Evolutionary. It's easy to use ,flexible and powerful tool to reduce your feature size.

zoofs is a Python library for performing feature selection using a variety of nature-inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics-based to Evolutionary. It's easy to use , flexible and powerful tool to reduce your feature size.

Jaswinder Singh 168 Dec 30, 2022
Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life.

Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life. The algorithm is designed to replicate the natural selection process to carry generation, i.e. survival of the fittest of beings.

Mahdi Hassanzadeh 4 Dec 24, 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
Minimal pure Python library for working with little-endian list representation of bit strings.

bitlist Minimal Python library for working with bit vectors natively. Purpose This library allows programmers to work with a native representation of

Andrei Lapets 0 Jul 25, 2022
A minimal implementation of the IQRM interference flagging algorithm for radio pulsar and transient searches

A minimal implementation of the IQRM interference flagging algorithm for radio pulsar and transient searches. This module only provides the algorithm that infers a channel mask from some spectral statistic that measures the level of RFI contamination in a time-frequency data block. It should be useful as a reference implementation to developers who wish to integrate IQRM into an existing pipeline / search code.

Vincent Morello 6 Nov 29, 2022
Repository for data structure and algorithms in Python for coding interviews

Python Data Structures and Algorithms This repository contains questions requiring implementation of data structures and algorithms concepts. It is us

Prabhu Pant 1.9k Jan 1, 2023
Python Client for Algorithmia Algorithms and Data API

Algorithmia Common Library (python) Python client library for accessing the Algorithmia API For API documentation, see the PythonDocs Algorithm Develo

Algorithmia 138 Oct 26, 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)

null 172 Dec 21, 2022
Slight modification to one of the Facebook Salina examples, to test the A2C algorithm on financial series.

Facebook Salina - Gym_AnyTrading Slight modification of Facebook Salina Reinforcement Learning - A2C GPU example for financial series. The gym FOREX d

Francesco Bardozzo 5 Mar 14, 2022
Planning Algorithms in AI and Robotics. MSc course at Skoltech Data Science program

Planning Algorithms in AI and Robotics course T2 2021-22 The Planning Algorithms in AI and Robotics course at Skoltech, MS in Data Science, during T2,

Mobile Robotics Lab. at Skoltech 6 Sep 21, 2022
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 2, 2022
All Algorithms implemented in Python

The Algorithms - Python All algorithms implemented in Python (for education) These implementations are for learning purposes only. Therefore they may

The Algorithms 150.6k Jan 3, 2023
Algorithms implemented in Python

Python Algorithms Library Laurent Luce Description The purpose of this library is to help you with common algorithms like: A* path finding. String Mat

Laurent Luce 264 Dec 6, 2022
A command line tool for memorizing algorithms in Python by typing them.

Algo Drills A command line tool for memorizing algorithms in Python by typing them. In alpha and things will change. How it works Type out an algorith

Travis Jungroth 43 Dec 2, 2022
Python sample codes for robotics algorithms.

PythonRobotics Python codes for robotics algorithm. Table of Contents What is this? Requirements Documentation How to use Localization Extended Kalman

Atsushi Sakai 17.2k Jan 1, 2023
🧬 Performant Evolutionary Algorithms For Python with Ray support

?? Performant Evolutionary Algorithms For Python with Ray support

Nathan 49 Oct 20, 2022
All algorithms implemented in Python for education

The Algorithms - Python All algorithms implemented in Python - for education Implementations are for learning purposes only. As they may be less effic

null 1 Oct 20, 2021