
Khan Academy: Algorithms - lobo_tuerto
https://www.khanacademy.org/computing/computer-science/algorithms
======
wodenokoto
When I first tried this course a few month ago, the little helpers (think
clippy) were driving me nuts!

Half way through writing a line of code they would pop up and tell me that my
code couldn't execute, maybe I should add a semi colon. It's really
distracting and of course code can't execute when you are in the middle of
typing an if-statement. It is not helpful at all.

On top of that there's no "submit" button (because it is supposed to test
continuously) so sometimes when I was done it wouldn't test the code and made
it impossible to get a "completion" on parts.

~~~
fafner
Yes, that's truly annoying. I have a few code examples that are complete but
it refuses to accept them without giving any reason. If I try to step forward
it says I have to go back.

Also in the first example it complained when I was using Math.round for the
index calculation and only wanted to accept Math.floor. (although not
applicable in this case, I think Math.floor is not the best choice since it
won't behave like ints in negative cases)

------
stevebot
Edit: Why the downvote? Disagree? I would love to hear more about why this
attitude is helpful.

I love algorithms, AND I think they are necessary in interviews, but I feel
like the tech community has become ridiculous in how they interview for them
lately.

Example problem: Given two words in a dictionary, transform one word into
another, changing one character at a time, using only words in the dictionary.

A good interview would recognize most people have no clue how to solve this,
give hints and still pass candidates who make a reasonable attempt but fail.
Now it seems to be that most places will just fail you, if you don't know the
most optimal answer and can't write it out without any syntax mistakes.

This is ridiculous, and I have experienced it and this attitude around major
tech companies. What this has resulted in is Algorithm trivia. Your ability to
succeed is your ability to memorize every algorithm question and approach in
existence.

~~~
jimmaswell
>Given two words in a dictionary, transform one word into another using only
words in the dictionary.

What's that supposed to mean? Search the dictionary for other words that
contain the letters you want and put them into the source word, while also
taking out unwanted letters from the source word?

~~~
stevebot
You have the additional requirement that you change one character at a time,
and end up building a graph of neighbors and doing BFS on it.

~~~
bmelton
I've never heard this question before, but I assume it's finding words with
the lowest Levenshtein distance between wordA and wordB and then wayfinding
the route from wordA to WordB using the least steps possible?

~~~
stevebot
correct, I think it is actually a good interview problem for discussion and
don't mind it. What I do mind is the attitude of some of my colleagues that if
a candidate can't immediately jump to the optimal answer, then they are a
pass.

~~~
chenglou
Can you englihten me on how edit distance helps here? I don't see why
insert/remove/move is relevant in this case.

------
symlinkk
I'm in college right now and I've been wondering...do professional programmers
actually think about sorting algorithms on a day-to-day basis? How relevant is
this knowledge when it comes to actually making something?

~~~
gleenn
I had a professor who told the class that if they ever wrote a sorting
algorithm professionally, they should be fired. Depending on where you go,
college is some cross between academia and training to get a job, and usually
biased towards academia. While not directly relevant to daily programming,
understanding time complexity and whats going on under the hood are very
useful for understanding many things that I do use on a regular basis.

For instance, adding an index to a database table is something I regularly do
for performance, and the reason is based on principles I learned in college.
The runtime complexity of an indexed table is way better. Any monkey coder can
add the index too, the difference is that I know what's going on under the
hood (finding things in a ordered tree data structure are way faster than
scanning through the whole table).

I was grumpy learning some things in college early on, and the more I advance
my career, the more I appreciate the things I learned even if I don't code
them up, or even use them, on a regular basis.

~~~
karmacondon
I realize that you chose one example off the top of your head, but it seems
like an incredibly rare case. The majority of developers can understand
"Queries involving this column are slow, it needs an index". Slightly more
sophisticated developers can use an EXPLAIN statement (or it's equivalent) to
see how many rows are being scanned and apply indexes where necessary. How
many hours of coursework is it worth to obtain the knowledge "finding things
in a ordered tree data structure are way faster than scanning through the
whole table"?

I'm not sure if I've ever run into anyone who said "The things I learned in
college have turned out to be pretty much worthless in my professional career.
I wasted a lot of time learning irrelevant information." It's interesting that
the majority of every CS education is _always_ valuable, to every person, with
no exceptions.

~~~
MichaelGG
Eh, you'd be surprised by the number of devs that simply don't know what
indexes are, other than magic-go-fast-juice. I've seen people put a separate
index on every column, so that "it'd be fast for all queries"...without
thinking that most of their queries used at least two predicates. I've seen
people go on to spend tons of time and money on things that fundamentally
cannot work because they simply are incapable of thinking through the
complexity of what their asking. The fact that modern systems are so fast can
let someone get pretty far before hitting a brick wall.

OTOH, I'm not sure full coursework is needed for that. Just make your way
through Sedgwick's algorithms book in a month or two and you're in the top 1%
probably.

------
jzelinskie
It's about time; this is great progress. it seems like they've updated a lot
of their computer science stuff -- it used to just be a basic introduction to
JS and not really anything theoretical.

------
RMarcus
For others who may be confused (as I was), note in the sidebar that this
course is for "introductory computer science algorithms." While I suppose it
is most certainly a collection of algorithms, I would generally expect such
topics to be listed under "data structures" or "discrete math" at most
universities.

In my experience, "algorithms" denotes a higher level, more advanced course
(OBSTs, flows, stable marriage, ILP/LP...)

~~~
quonn
While the algorithm course at my university consisted mostly of calculating
complexities and was much more difficult in general, there is also Sedgewicks'
Algorithms book, which covers many of the topics in this course. So
"algorithms" is certainly the correct term.

------
eliben
Taught by Cormen, no less

------
graycat
Gee, I saw quicksort but not heap sort!

Heap sort is O( n log(n) ) in all cases including worst, and quicksort is O(
n^2 ) worst case. O( n log(n) ) is the Gleason bound, the fastest sort there
can be on average from comparing pairs of keys so that in that sense heap sort
is asymptotically the fastest possible. Dropping the technique of comparing
pairs lets us consider radix sort which can be faster, still. The lecture does
cover merge sort; good.

For graphs, the min cost network flow problem is linear programming, and it
turns out that if the arc capacities are integers and start with a basic
integer feasible solution, then the simplex algorithm maintains integer
solutions and, if merely an optimal solution exists, will find an optimal
integer solution.

It turns out that this fact is in practice one of the best tools for linear
integer programming which generally is in NP-complete. This progress on
integer programming is worth noting.

For cycling in the simplex algorithm for the min cost flow problem on
networks, W. Cunningham, long at Waterloo, has a nice solution based on what
he calls _strongly feasible_ basic solutions.

For the simplex algorithm for the network flow problem, there are, compared
with the simplex algorithm in general, some enormous simplifications -- e.g,.
a feasible basis corresponds to a spanning tree of arcs -- and, thus,
astoundingly high performance on astoundingly large problems -- this fact
should be noted.

Maybe I missed it, but I didn't see trees mentioned. Both AVL trees and red-
black trees are good examples, that is, balanced binary trees good for
_collection classes_. And B-trees, multi-way branched balanced trees, long
important on hard disk (and likely now on solid state disks) for database
should also be mentioned.

Since need to teach heap sort, should also mention that the heap data
structure is good for an easy implementation of fast priority queues, e.g.,
look at 1 billion numbers one at a time, in any order, and end up with the 100
largest, efficiently. Also there is a modification of the heap data structure
that has good locality of reference when doing a lot of virtual memory paging.

And for hashing, the clean solution is

Ronald Fagin, Jurg Nievergelt, Nicholas Pippenger, H. Raymond Strong,
Extendible hashing-a fast access method for dynamic files', "ACM Transactions
on Database Systems", ISSN 0362-5915, Volume 4, Issue 3, September 1979,
Pages: 315 - 344.

I'm not thrilled with recursion since in practice it can strain
implementations of the call stack.

Course over. Hope you enjoyed it!

------
rfrey
graycat: you may be hellbanned. (I don't see anything obnoxious in your
comment history which is why I mention it.)

------
edem
For some reason when I read "Khan Academy" somewhere I instantly associate it
with Star Trek and I can't take it seriously.

~~~
rm445
Well done, you've noticed a tremendous character flaw and now you can strive
to correct it.

Honestly, how are you going to live life if any reminder of pop culture can
distract you from a serious subject? And how are you going to interact with
people if noticing such a thing (even if it's tremendously obvious) makes you
feel the need to shout about it? Best to knock it on the head now.

~~~
benihana
Jesus dude. It was just an anecdote. It's a hell of a thing to call that a
"tremendous character flaw" based on like, literally no evidence other than
your assumptions.

~~~
rm445
Just for clarity, genuinely being incapable of taking anything seriously which
sounded like a pop culture reference, would indeed be a tremendously damaging
flaw.

Of course I don't really believe parent poster has that problem: it was making
a little fun as mild chastisement for the terrible comment. I honestly think
you could have interpreted it correctly if you hadn't been so quick to take
offence.

~~~
randomnumber53
If you don't actually believe the poster has that problem, why respond the way
that you did? Doesn't that make your comment at least as terrible?

