Rust icon indicating copy to clipboard operation
Rust copied to clipboard

Algorithms and datastructures road map

Open erfan-khadem opened this issue 2 years ago • 21 comments

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)

erfan-khadem avatar Jul 03 '22 04:07 erfan-khadem

Hash Array Mapped Trie (HAMT) ?

Seems like a cool datastructure!

Should I add it as WIP by you @YurySolovyov ?

erfan-khadem avatar Aug 22 '22 17:08 erfan-khadem

Hash Array Mapped Trie (HAMT) ?

Seems like a cool datastructure!

Should I add it as WIP by you @YurySolovyov ?

No, I'm still relatively new to rust, so I don't want to claim this item, it was purely a suggestion. HAMT combines hashing, trees and some binops, so I was hoping to learn how it can be done, that's all.

YurySolovyov avatar Aug 22 '22 17:08 YurySolovyov

No, I'm still relatively new to rust, so I don't want to claim this item, it was purely a suggestion. HAMT combines hashing, trees and some binops, so I was hoping to learn how it can be done, that's all.

Maybe you can start by implementing the hash function for HAMT first, because datastructures are known to be a bit tricky to implement in rust, and this certainly isn't a trivial one.

In any case, you are more than welcome to contribute. Some other options you have are: ~~1- ChaCha20~~. Just open RFC8439 and start writing code. This can be implemented in ~30 LoC. ~~2- All Pairs Shortest Path.~~ 3- Bipartite matching. Use Dinic which is already implemented.

Edit: No.1 was implemented. Poly1305 specs can be found at the same RFC, but implementing it is a bit more challenging.

erfan-khadem avatar Aug 22 '22 17:08 erfan-khadem

@siriak Can we use a third party library for bignum support? I really want to implement some cool stuff with elliptic curves (e.g. Lenstra ECM, Diffie-Hellman, MQV method, etc.), but creating bignum support from scratch is a big undertaking and a bit futile (either the code won't be readable/educational, or would be prohibitively slow). Maybe we can hide the code that depend on 3-rd party library behind a feature flag, such that "normal" builds don't pull the dependency?

erfan-khadem avatar Aug 27 '22 12:08 erfan-khadem

@er888kh Are you talking about BigInteger and BigDecimal from java.math? Sure

siriak avatar Aug 30 '22 04:08 siriak

@er888kh Are you talking about BigInteger and BigDecimal from java.math? Sure

Yes. I'm not sure if using one of the gmp interfaces makes sense (I don't have windows, I'm not sure whether windows users can easily compile gmp C library or whether it can be retrieved automatically), but in case that's possible, it would be the best solution.

The other solution is to use one of the native rust based implementations. But that would come with a hefty performance penalty (nothing beats literally decades of hand optimized assembly code).

erfan-khadem avatar Sep 03 '22 13:09 erfan-khadem

Ooops, wrong repo :) I thought it was in the Java repo :) I don't have a Windows pc either, so can't comment about gmp. It's up to your discretion as I don't have an opinion on that matter

siriak avatar Sep 04 '22 15:09 siriak

@siriak I implemented poly1305 using num-bigint library. Once that is merged, we can move on to other stuff. For example elliptic curve code shouldn't be that hard once I implement some primitive operations/algorithms.

erfan-khadem avatar Sep 05 '22 11:09 erfan-khadem

Could I request the A* (a.k.a. A-star) graph search algorithm wiki?

See the original paper and possibly the NetworkX implementation.

EwoutH avatar Sep 06 '22 20:09 EwoutH

Could you please look at my PR #377 for Bipartite Matching. If found suitable, I can add Hopcroft Karp in a similar fashion

Arjun31415 avatar Sep 18 '22 16:09 Arjun31415

Hi, if anybody could review my PR https://github.com/TheAlgorithms/Rust/pull/378

GentBinaku avatar Sep 20 '22 10:09 GentBinaku

Hi, if open I would like to pick up "Chinese Remainder Theorem" under the "Math" category.

Logicless-Coder avatar Oct 28 '22 10:10 Logicless-Coder

@Logicless-Coder https://github.com/TheAlgorithms/Rust/pull/413 if you think you can improve it please go ahead and make a commit

GentBinaku avatar Oct 28 '22 10:10 GentBinaku

@GentBinaku are there any known issues/bugs/improvements?

Logicless-Coder avatar Oct 28 '22 10:10 Logicless-Coder

@Logicless-Coder The test pass and the checks pass, so you might dig more into it if you want too

GentBinaku avatar Oct 28 '22 10:10 GentBinaku

@GentBinaku The test cases were weak, I found a test which fails and found the problem being in the modinverse function. It requires usage of extended Euclidean algorithm and not just the regular Euclidean algorithm of calculating GCD. I am writing the extended algorithm next to verify this claim.

Logicless-Coder avatar Oct 28 '22 11:10 Logicless-Coder

@Logicless-Coder Please do I would like to see the code

GentBinaku avatar Oct 28 '22 11:10 GentBinaku

Hi admin, i would like to work on Eulerian path

LeTsC0D avatar Oct 01 '23 00:10 LeTsC0D

Hi , Suffix array can be implemented using external crate "suffix" with lesser lines of code ensuring optimistic code. So, should i add it to this ? OR implement it using Manber-Myers algorithm which doesn't uses external crate but it can become more complex ?

mohit07raghav19 avatar Oct 01 '23 13:10 mohit07raghav19

What do you mean by using suffix crate? Just using their implementation of suffix array? I'd say using Manber-Myers algorithm is preferable because we must see implementation details

siriak avatar Oct 01 '23 13:10 siriak