All Algorithms implemented in Rust

Comments
  • Add project euler directory and problem 3 solution

    Add project euler directory and problem 3 solution

    This PR adds a project_euler directory and a few guidelines to the respective readme. Project Euler solutions were originally requested in #3.

    It also adds a solution for problem 3.

    stale 
    opened by MonliH 11
  • Add project euler

    Add project euler

    This PR adds a project euler section to the repo and includes an example solution for problem 1 This mirrors the python repo seen here https://github.com/TheAlgorithms/Python/tree/master/project_euler

    stale 
    opened by darakian 9
  • open to adding benchmarks?

    open to adding benchmarks?

    hey, I recently had an assignment where I had to benchmark two sorting algorithms(selection and quick) against each other in order to create a hybrid, and did this using the sorting algorithms from this repository. I wrote the benchmarks using criterion, and was wondering if you would be open to adding benchmarks to this repository, it should be fairly trivial to take the benchmarks I created and refactor them to do benchmark all the comparative based sorting algorithms against each other.

    you can find the benchmarks here and I'll be adding the markdown version of the actual report shortly

    stale 
    opened by skewballfox 7
  • Add Cipolla algorithm for Quadratic Residue problem

    Add Cipolla algorithm for Quadratic Residue problem

    Cipolla algorithm for Quadratic Residue problem

    Solving quadratic residue problem: x^2 = a (mod p) , p is an odd prime with O(M*log(n)) time complexity, M depends on the complexity of complex numbers multiplication.

    Wikipedia reference: https://en.wikipedia.org/wiki/Cipolla%27s_algorithm If a is Quadratic Nonresidues, return None; Otherwise return two solutions (x1, x2)

    opened by itewqq 6
  • Added Miller Rabin primality test

    Added Miller Rabin primality test

    Added Miller Rabin test.

    I was wondering if some graph algorithms should be added. I think we are missing quite a few important and useful algorithms (all pairs shortest path, bipartite matching, max flow, ...). What do you think should be implemented first (graph or otherwise)?

    opened by er888kh 6
  • LinkedList leaks Node memory when dropped

    LinkedList leaks Node memory when dropped

    The linked_list module stores references to nodes using NonNulls that are never dropped at any point. Unless there is something I missed, this code doesn't ever free the memory allocated to the nodes.

    bug dont-close 
    opened by Kylebrown9 6
  • Hacktoberfest

    Hacktoberfest

    With Hacktoberfest coming, I thought it might be a good idea to devise a strategy beforehand so that our contributors and community can make the most out of this event.

    There are many, many algorithms out there, with variable degree of utility, that can be implemented by contributors, but most of them won't be of particular value, even though they can't be rejected. For example we won't be benefiting from yet another sorting algorithm with terrible run time behavior that was mentioned in $textbook.

    As such, it might be a good idea to somehow curate a to-do list with tasks of various difficulty levels for participants. The tasks need not be strictly coding related, but I can think of at least a few areas where we could benefit from having lots of new code (bignum, random and crypto to name a few.)

    We can also start thinking of a new direction: Something like collecting all the accumulated knowledge here in a book or blog like platform to guide not only new learners, but also enthusiasts that could benefit from "human-readable" implementations of complex systems (like cryptography or random number generation for instance). One thing to keep in mind with this approach is that it will take a lot of polishing before it becomes anything useful.

    To summarize, we need a strategy to make the most of this year's hacktoberfest. At very least a to-do list for new code and algorithms, but we may decide (and vote) to start being something more than a "just" repository to store algorithms. I think this issue might be a good place to start discussing our options.

    stale 
    opened by er888kh 5
  • Open to hybrid algorithms?

    Open to hybrid algorithms?

    this is something we are covering in my algorithms course. it's possible to create algorithms that switch between different strategies based off the size of the input. for example this hybrid of selection sort and quick sort (using Hoare's partition scheme consistently outperforms a regular quick sort by a constant factor:

    `
    pub fn hybrid_quick_sort<T>(arr: &mut [T])
    where
        T: Ord + Clone,
    {
        let len = arr.len();
        if len > 17 {
            _hybrid_quick(arr, 0, len - 1)
        } else {
            selection_sort(arr)
        }
    }
    
    fn _hybrid_quick<T>(arr: &mut [T], lo: usize, hi: usize)
    where
        T: Ord + Clone,
    {
        if lo < hi {
            if hi - lo > 17 {
                let p = partition(arr, lo, hi);
                _hybrid_quick(arr, lo, p);
                _hybrid_quick(arr, p + 1, hi);
            } else {
                selection_sort(&mut arr[lo..hi + 1]) //from first element to include to first element to exclude
            }
        }
    }
    
    
    stale 
    opened by skewballfox 5
  • it seem that I found some error in heap

    it seem that I found some error in heap

    I remember that rust's index is from 0, and your code is

    pub fn add(&mut self, value: T) {
            self.count += 1;
            self.items.push(value);
    
            // Heapify Up
            let mut idx = self.count;
            while self.parent_idx(idx) > 0 {
                let pdx = self.parent_idx(idx);
                if (self.comparator)(&self.items[idx], &self.items[pdx]) {
                    self.items.swap(idx, pdx);
                }
                idx = pdx;
            }
        }
    

    the idx should be self.count - 1 and the parent_index, left_child_index, right_index are wrong too, the parent_index should be (index - 1) / 2, left_child should be 2 * index + 1, right_child should be 2 * index + 2

    opened by nesteiner 5
  • Constraint Satisfaction Problem

    Constraint Satisfaction Problem

    There are multiple problems in the repo that fall under CSP. Essentially a list of variables and constraints between them. It is not an algorithm but a class of problems that can be modeled in such a way, such as sudoku, n queens, graph coloring. There are multiple ways to solve them, one being backtracking. Could be considered a data structure? Otherwise I don’t know where it would live. I recently did an assignment for school in golang to make a sudoku and killer sudoku solver where we convert to a generic CSP to solve.

    Where could this live in the repo? It’s difficult to define every constraint that a problem would use but you can cover most problems with EQUALS and NOT_EQUALS constraints. Or maybe there is a good way to define constraints by passing in some lambda functions. I’m not super experienced in rust but this could be something I’d be interested to contribute.

    opened by MVanderloo 2
  • fix: floyd warshall d[i][i] == 0 case

    fix: floyd warshall d[i][i] == 0 case

    In the existing logic, if $u == v$, $v$ is considered as unreachable, while the distance (or cost) should be $0$ instead. This PR is to add that logic and corresponding test cases.

    opened by wingkwong 1
  • Define generic matrix struct and macro

    Define generic matrix struct and macro

    Generic matrix struct and macro

    Description

    As a personal exercise, I tried to implement a Matrix struct which encompasses all matrix operations defined in the matrix_ops.rs file and also some custom ones. I used a custom trait MatrixElement to make it generic and you can build matrices idiomatically using the "matrix!" macro.

    I'm not quite sure how useful this is, it was made as a learning experience for myself, but I'm making a pull request just in case. Also, any feedback is very much appreciated as rust is very new to me still.

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    Checklist:

    • [x] I ran bellow commands using the latest version of rust nightly.
    • [x] I ran cargo clippy --all -- -D warning just before my last commit and fixed any issue that was found.
    • [x] I ran cargo fmt just before my last commit.
    • [x] I ran cargo test just before my last commit and all tests passed.
    • [x] I checked COUNTRIBUTING.md and my code follows its guidelines.
    opened by EduardoFarinati 2
  • Algorithms and datastructures road map

    Algorithms and datastructures road map

    Since #3 is already overcrowded and we need to have our roadmap somewhere visible, I figured I should open a new issue. The list is currently my own to-do list, and maintainers' suggestions, additions, and ideas in general will be incorporated here. Also suggestions from community are welcome.

    Maths

    • [x] Big number support (#371)
    • [ ] Chinese remainder theorem (WIP @Logicless-Coder)
    • [ ] Elliptic curve operations

    Graph

    • [x] 2-SAT (#345 )
    • [ ] Eulerian path
    • [x] All pairs shortest path (#366)
    • [ ] Bipartite matching
    • [ ] A*

    Strings

    • [ ] Suffix array
    • [ ] Suffix tree

    Cryptography

    • [x] A generic implementation for HMAC (#351)
    • [x] Salsa20 and Chacha20 (#363)
    • [x] Poly1305 message authentication code (#371)
    enhancement dont-close 
    opened by er888kh 18
Owner
The Algorithms
Open Source resource for learning Data Structures & Algorithms and their implementation in any Programming Language
The Algorithms
Rust-algorithm-club - Learn algorithms and data structures with Rust

Rust Algorithm Club ?? ?? This repo is under construction. Most materials are written in Chinese. Check it out here if you are able to read Chinese. W

Weihang Lo 360 Dec 28, 2022
Coding-challenge - Algorithms and Data-structures, problems and solutions in Rust language using cargo-workspaces

Coding Challenge LeetCode/Hackerrank e.t.c Using this as an opportunity to improve my knowledge of rust lang If you found this repo useful to you, add

Tolumide Shopein 17 Apr 24, 2022
Common data structures and algorithms in Rust

Contest Algorithms in Rust A collection of classic data structures and algorithms, emphasizing usability, beauty and clarity over full generality. As

Aram Ebtekar 3.3k Dec 27, 2022
Fastest solutions for various Rust algorithms from challenges

Algs These are the results of going through various challenges and solutions to find the fastest and most concise algorithms. It is structured by data

Jack Clayton 1 Jan 20, 2022
rust_aads - Rust Algorithms And Data Structures

rust_aads - Rust Algorithms And Data Structures rust_aads is an open repository with algorithms and data structures, used in computer science and comp

stepa 2 Dec 15, 2022
Library containing various Data Structures implemented using Rust.

rust-data-structures Library containing various Data Structures implemented using Rust. Running You can test the library by running cargo test, an exa

c1m50c 1 Jan 6, 2022
A number of collections, such as linked-lists, binary-trees, or B-Trees are most easily implemented with aliasing pointers.

StaticRc is a safe reference-counted pointer, similar to Rc or Arc, though performing its reference-counting at compile-time rather than run-time, and

null 372 Dec 19, 2022
Conditional compilation using boolean expression syntax, rather than any(), all(), not()

Conditional compilation expressions Conditional compilation using boolean expression syntax, rather than any(), all(), not(). [dependencies] efg = "0.

David Tolnay 298 Dec 28, 2022
Ternary search tree collection in rust

tst Ternary search tree collection in rust with similar API to std::collections as it possible. Ternary search tree is a type of trie (sometimes calle

Alexey Pervushin 20 Dec 7, 2022
Array helpers for Rust's Vector and String types

array_tool Array helpers for Rust. Some of the most common methods you would use on Arrays made available on Vectors. Polymorphic implementations for

Daniel P. Clark 69 Dec 9, 2022
Generic array types in Rust

generic-array This crate implements generic array types for Rust. Requires minumum Rust version of 1.36.0, or 1.41.0 for From<[T; N]> implementations

Bartłomiej Kamiński 325 Dec 25, 2022
A priority queue for Rust with efficient change function.

PriorityQueue This crate implements a Priority Queue with a function to change the priority of an object. Priority and items are stored in an IndexMap

null 139 Dec 30, 2022
K-dimensional tree in Rust for fast geospatial indexing and lookup

kdtree K-dimensional tree in Rust for fast geospatial indexing and nearest neighbors lookup Crate Documentation Usage Benchmark License Usage Add kdtr

Rui Hu 152 Jan 2, 2023
Roaring bitmap implementation for Rust

RoaringBitmap This is not yet production ready. The API should be mostly complete now. This is a Rust port of the Roaring bitmap data structure, initi

Roaring bitmaps: A better compressed bitset 552 Jan 1, 2023
Rust Persistent Data Structures

Rust Persistent Data Structures Rust Persistent Data Structures provides fully persistent data structures with structural sharing. Setup To use rpds a

Diogo Sousa 883 Dec 31, 2022
Rust crate to extend io::Read & io::Write types with progress callbacks

progress-streams Rust crate to provide progress callbacks for types which implement io::Read or io::Write. Examples Reader extern crate progress_strea

Pop!_OS 19 Dec 3, 2022
Parameterized routing for generic resources in Rust

Usher Usher provides an easy way to construct parameterized routing trees in Rust. The nodes of these trees is naturally generic, allowing Usher to le

Isaac Whitfield 34 Oct 22, 2022
RiteLinked - LinkedHashMap & LinkedHashSet in Rust

RiteLinked -- HashMap-like containers that hold their key-value pairs in a user controllable order RiteLinked provides more up to date versions of Lin

Rite Database 52 Aug 19, 2022
A proof of concept implementation of cyclic data structures in stable, safe, Rust.

A proof of concept implementation of cyclic data structures in stable, safe, Rust. This demonstrates the combined power of the static-rc crate and the

null 157 Dec 28, 2022