r/compsci • u/TopcatTomki • Aug 14 '13
Algorithims Everyone Should Know?
What are some of you're favourite algoritms or concepts that you think everyone should know, whether they solve problems that crop up frequently, or are just beautiful in their construction?
375
Upvotes
View all comments
Show parent comment
14
u/slapnuttz Aug 14 '13
I love me some merge sort. It is always the same O time. However, bubble sort beats out merge, quick, shell, insertion, and a few other sorts for very small data sets, which is why some 'sorting books' teach hybrid approaches where you do X sort until you are sorting a data set of 10 or less then bubble sort it.
More importantly however, you should know bubble sort for 2 reasons. 1 is that it is the most natural of sorts, so you know it regardless. 2 You should know what NOT to do in regular practice and know that you need to question your instincts given reason 1.