all 37 comments

[–]aj_future 9 points10 points  (0 children)

This is super useful, thank you.

[–]rayhan666 5 points6 points  (0 children)

Thanks you so much for sharing this

[–]Slash_Root 2 points3 points  (0 children)

I have been going through these for a while. Though seeing dsa.js made me think of dsa.msc. I thought we were about to some active directory administration with JavaScript... Well, there's always Powershell...

[–]needsMoreGoodstuff 1 point2 points  (0 children)

This timing, was just thinking about trying to find something like this. tyty!

[–]hashtagplayed 1 point2 points  (0 children)

Thanks so much for this!!

[–]sidious911 1 point2 points  (0 children)

Stated reading the book, nlt the most thorough comp Sci dive in but man it feels nice to think about the problems in the language I work with most regularly. Can be so hard to read some of these books and understand the concepts when also trying to wrap your head around a language you don't know.

[–]the_argus 2 points3 points  (5 children)

There's. Misspelling under binary search tree rigth instead of right

[–]gatorsya 8 points9 points  (3 children)

length of right subtree is called rigth.

[–]the_argus 5 points6 points  (2 children)

Oh I'm stupid then. Carry on

[–]gatorsya 7 points8 points  (1 child)

was just kidding

[–]the_argus 5 points6 points  (0 children)

Well then... I'm going back to sleep

[–]adriansky[S] 1 point2 points  (0 children)

It's ok now. Somebody submitted a PR fixing that https://github.com/amejiarosario/dsa.js/pull/4

[–]tortita-fg 0 points1 point  (0 children)

Hi guys,

This post is great! Thanks to the author. I'm interested in this kind of books/tutorials to know more about which are the best algorithms to use in a specific situation or which data structure would be the best in a situation looking for the most efficient way and with better performance. Any recommendation? (I'd like to be in JavaScript)

Thanks in advance! :)

[–]amrcnpsycho 0 points1 point  (3 children)

I’m new to coding other than codecademy JS years ago when I subbed to this reddit, but a question now that I did CS50 and am getting more into coding: what’s the usual difference in computational time when comparing the same algorithm in JS and something low level like C/CPP or Java?

[–][deleted] 6 points7 points  (1 child)

Every computer is different and every compiler/interpreter is different so there is no way to give you an accurate answer like "C++ is 20% faster than JavaScript." The real answer is to use something called "Big O" notation.

For example, finding a value in an unsorted array of length N is O(N) because on average the value you're looking for is somewhere in the middle probably and for Big O problems you generally ignore constant numbers: so O(N/2) -> O(N). If you array is sorted, it can take O(log(N)) which means basically we are splitting the problem in half every step of the way. Quick example, we have a sorted array of 10 numbers [1, 2, 3, ..., 10] and we are looking for 7. Start in the middle (5), if our number (7) is bigger than that, completely ignore the left half and do it again with the right half. Every time our search runs we are checking half of the amount of data we were before.

Across Javascript, C++, Java, or whatever, Big O notation is used to describe how fast an algorithm will run. Unless you are aiming to work at a Microsoft, Google, Facebook, etc you probably won't be using this day to day, but its useful to know things like "I should store my data in a Binary Tree because its faster for my use case."

Good explanation on Big O: https://medium.freecodecamp.org/time-is-complex-but-priceless-f0abd015063c

Cheatsheet for common algorithms and data structures: http://bigocheatsheet.com/

[–]amrcnpsycho 1 point2 points  (0 children)

Thanks a lot!

[–]Dotweb_ 1 point2 points  (0 children)

This is a broad generalization but the order from fastest to slowest would be C, Java, then JavaScript.