Anybody attempted Coursera's "Advanced Algorithms and Complexity" with Elixir?

Has anybody attempted to do exercises for using Elixir? I might try in a week and I was hoping to hit the ground running.


Posted something else but can’t seem to delete. Got excited thinking there was coursera course on algos that used elixir. Didn’t realize you were asking if anyone has chosen to do the course in elixir haha.

I can’t speak to that particular course, but in general you might encounter some headaches doing “traditional” data-structures work in Elixir because the textbook algorithms frequently rely on mutable state.

For instance, structures like a queue that would be represented with a doubly-linked list need to be more clever with immutable data - take a look at the :queue module in the Erlang standard library.

Some things might also be easier: for one, network flows sound like the :digraph module might help.


Is there an online course similar to the one in this thread for functional languages? Purely Functional Data Structures by Chris Okasaki is the most popular book on this topic I’ve seen.


I am interested in diving deeper into complexity theory, so I am just trying out an algorithm course close to that topic.

I may use elixir because it is the language that I want to be fluent in right now.

Is there any escape hatch for implementing mutable data structures? Or are the only options to bind to code written in another language?

You can use a gen server to mimic mutable state. I have had to resort to that for certain Leetcode problems where the tests are not written with immutable state in mind. Before I get caught out, let me just say that I know that is not really the use case for gen servers exactly. But in certain situations it’s the best workaround that I have found.

1 Like

There are some options for doing mutable-state-ish things, but they’re not a one-size-fits-all solution. For instance, I wrote a doubly-linked list implementation backed by ETS for an Advent of Code problem a couple years ago.

If you’re specifically looking to get into complexity theory more, you’ll also encounter common operations with radically different performance characteristics; for instance, accessing the nth element of an array in a C-like language takes a constant amount of time (a single pointer offset) but the naturally corresponding operation ( in Elixir takes time proportional to n because it has to traverse the preceding elements. There are alternatives (like Erlang’s :array module) but you’ll need to already grasp at least some complexity theory to understand the tradeoffs involed.

I will just use python for this and use elixir for other projects.