Algorithms and Data Structures Explained and Implemented in JavaScript

deckermann | 483 points

The documentation and code quality is all good.

The implementation choices leave some things to be desired. The Queue and Stack implementations are Linked Lists instead of array backed, the hash table is closed instead of (the only barely more complicated) open Robin hood hash table scheme, the union-find/disjoint-set implementation doesn't have path compression or rank unions.

Overall very good, but it could be Great (tm) with just a little bit of work.

eximius | 6 years ago

This repo is beautiful. The README is detailed and clear, and the contents seem pretty exhaustive. As a native JS guy I'm especially excited to check out the implementation of non-tree graphs!

Having said all that: The algorithms I've had to tackle at work tend to be fairly trivial or total one-offs involving scheduling events in human time.

How much algorithmic work do you other JS folks end up doing?

teachrdan | 6 years ago

Had the same idea and got sad you got there faster. But then I looked at the code and realized you did it better than I would have done it so good job!

superkarolis | 6 years ago

I like it! Something I've been thinking about recently is using ES6 proxies to visualize algorithms like this. Lay out the arrays and objects as blocks on a canvas, and highlight the blocks as the algorithm reads / writes to the corresponding slots of the arrays / objects.

chatmasta | 6 years ago

This is a terrific idea! The code I reviewed so far looks very well written. Thanks for this... folks looking to interview for a software developer position (especially at Google or with any group that emphasizes fundamentals) would do well to get acquainted with this repo!

slathrop | 6 years ago

I would be interested in hearing feedback on this book [1]. I bought it for a friend who's getting started with programming, coming from a different field. It seems a good book overall, but I haven't had the time to take a very deep look at it.

[1] https://www.packtpub.com/web-development/learning-javascript...

evacchi | 6 years ago

Tangential, but is there a name for a Trie that isn't for string searching/matching? I've had a need for this in the past but each node needed to store a non-character value. This was to facilitate a sort-of path finding where the input was matched against a known set of paths.

Every library I looked at had implementations revolving around nodes that stored chars (you know, for auto-complete scenarios) but nowhere in the definition of a Trie is it bound to such an implementation (so I thought).

crescentfresh | 6 years ago

I'd love to see something like this for every language... similar to the to do app which has become the de facto standard to compare web frameworks..

ethanpil | 6 years ago

If anybody wants to build it into a library I threw together an index file and included the rollup run to allow you to import everything as one library or as separate modules:

https://gist.github.com/robertfairley/11ba23640578650671dbde...

52-6F-62 | 6 years ago

Along similar lines, does anyone know of something similar that includes multigraphs? (Graphs with parallel edges).

There's a python library called networkx, but it is so heavily object-oriented (multi-inheritance) as to make it impossible to get any benefit from reading the code.

dmayle | 6 years ago

Damn I’d just started doing something similar on the side. Looks like I’ll have to rethink my efforts. :)

Nicely done

52-6F-62 | 6 years ago
[deleted]
| 6 years ago

Seems like a good reference manual to use before attending an interview at Google/Amazon/Facebook etc

djhworld | 6 years ago

They don't explain lock-free data-structures?

amelius | 6 years ago

Bookmarked! Well done.

tommerbomb | 6 years ago

is there a similar thing with python too ?

sciencesama | 6 years ago

Gold!

jonjojr | 6 years ago