4 ms·
You could probably implement any of them in JavaScript, but it would be sort of silly, because the actual runtime complexity and memory usage aren't really goin
by javert 14y ago
You could probably implement any of them in JavaScript, but it would be sort of silly, because the actual runtime complexity and memory usage aren't really going to be close to what they "should be" due to the interpreter.
I haven't given it a lot of thought, but I doubt it makes sense to implement "textbook" algorithms and data structures without pointers.
- mistercow 14y agoAs I said in another thread, you can get the same functionality as pointers by using arrays or objects, which are always passed around by reference. You're right that this is an inefficient way to implement those algorithms, but I disagree that that makes it silly. The purpose of writing those algorithms is to learn how they work, not to use them in practice. Generally, if you're using them in practice, you shouldn't be rolling your own in the first place.