Live data from Hacker News

Algorithms and Data Structures Explained and Implemented in JavaScript

github.com

1–10 of 45 posts

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#2
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?

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#3
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.

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#4

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?

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

I recently built a questionnaire/form editor/builder which relies heavily on tree structures. I ended up writing a lot of tree walking code. It was the first time I've ever needed to implement interview-like questions in an actual project.

I make heavy use of functional programming in Javascript, which lends itself to really clean implementations of algorithms like tree walking, e.g.: https://hastebin.com/qapawepavi.js

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#5
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!

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#7
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).

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#8

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…

I think that is just the common use case.

It shouldn’t be too hard to roll your own here, it’s just a set of tree traversal functions.

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#9

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…

Here's mine: https://github.com/superlopuh/SuperTrie

I've implemented at least 5 different generic Tries since this one. The idea is almost always the same, but different tradeoffs can require different implementations. While I don't recommend that you use this version, the contents of [1] should give you all the inspiration you need to roll your own.

[1] https://github.com/superlopuh/SuperTrie/blob/master/SuperTri...

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#10

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…

I think that is just the common use case. It shouldn’t be too hard to roll your own here, it’s just a set of tree traversal functions.

Oh I did, was just surprised every formal language had one tied to string searching/matching, including this demo.
Post reply on HN