sashaafm

sashaafm

Hi everyone, some time ago I started building an algorithm and data structures collection for Elixir. My goal is to build the best and most complete collection of algos and ADS’s for Elixir, to be available for everyone to use as they need. So far I’ve started implementing the most popular data structures, like the Stack, Queue and Binary Search Tree. However, in order to have a really good collection that’s robust and complete, I will surely need some contributions.

I’m taking contributions in every form, be it corrections, new implementations, new algorithms or data structures or even test suites for the existing ones. Everyone’s free to contribute and I’ll accept most contributions as long as they reach a decent standard of quality (decent code, justifications for changes, and so on). But hey, even if you’re not sure if it’s good, please send them to me and maybe we’ll work together on it to make it better and merge it into the project. There’s a lot of people learning Elixir in this community and I think this would be a great way to learn and get some experience with the language.

Here’s the repo: Exads

In the README you have a roadmap of the algos and ADS’s I have on my mind right now, but I plan to implement more than those, so feel free to work on whatever you like, even if it’s not in the roadmap right now.

I’ve been writing some stories on Medium about this project. I just posted the second chapter about implementing the Binary Search Tree: Implementing the BST

As I’ve said, everyone’s free to help and also to critique my work (and writing skills) as long as it is constructive and helpful :slight_smile:

Showing Posts 1 to 10

AstonJ

AstonJ

Good luck with this Sasha - sounds like an interesting project :slight_smile:

ramonsnir

ramonsnir

Really awesome, and really useful! Starred for future reference :smile:

sashaafm

sashaafm OP

Thank you @ramonsnir :slight_smile: Please feel free to contribute in any way if you want. We’re two people working on it so far.

uranther

uranther

I opened a pull request to add Travis CI and Inch CI badges :slight_smile: Cheers!

sashaafm

sashaafm OP

@uranther Thank you! Already merged and resolved the conflicts for both Travis CI and Credo. The build is passing :slightly_smiling:

Next I’ll be looking to implement the Inspect behaviour and maybe review the Priority Queue based on some things @NobbZ and me talked about.

One thing I thought of is to look at Enum.sort and see if we can implement a better algorithm (if possible).

uranther

uranther

I noticed you mentioned you are basing your algorithms & data structures on those in Introduction to Algorithms. I took a peek, and about lost it at the stateful, imperative implementations of the algorithms. I guess that is to be expected, but it makes it difficult to translate to a functional language.

For example, compare the imperative pseudo-code of insertion sort with its implementation in Haskell. The latter is so much easier to understand because it captures the high-level concepts.

Check out Purely Functional Data Structures by Chris Okasaki. This book may be more helpful for this project, although it doesn’t have all the ADS you list in the README. There’s also Pearls of Functional Algorithm Design.

Elixir just uses :lists.sort, which is an implementation of merge sort (source).

sashaafm

sashaafm OP

Yes, I’ve been refering to it because it’s the “standard book” for Algos and ADS (at least it is in most universities I’ve checked, including mine). I didn’t know about that Purely Functional Data Structures book, I’m going to check it out :slight_smile: Thanks!

I still hadn’t checked Elixir’s implementation. In that case, shouldn’t Quicksort be better in terms of space, because of in place sorting? Not sure if this only applies to the imperative languages.

uranther

uranther

According to the internets:

Merge sort is often the best choice for sorting a linked list: in this situation it is relatively easy to implement a merge sort in such a way that it requires only Θ(1) extra space, and the slow random-access performance of a linked list makes some other algorithms (such as quicksort) perform poorly, and others (such as heapsort) completely impossible.

Seems to make sense. Maybe there are more advanced sorting algorithms that are well-suited for linked lists?

Another option is to parallelize the merge sort. :astonished:

sashaafm

sashaafm OP

I’ll assign this task for myself, if you don’t mind (research about better sorting algos and write a parallel merge sort) :slightly_smiling:

ejc123

ejc123

I will second this book. It goes into details about performance in FP style that most of us (or me at least) didn’t get in Algorithms class. Those classes seem to focus on imperative style analysis. This book introduces amortization and banker’s method. You can check out the full text here.

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews