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?
378
Upvotes
View all comments
Show parent comment
3
u/Porges Aug 14 '13
Mergesort can be done in-place (Knuth, as usual, has an exercise for this).
Mergesort is also important because it can be easily parallelized. You can also do a hybrid Mergesort and use QuickSort on each processor for sorting its portion and then Mergesort to put them all back together.
Timsort (the default sort in Python & the JDK, along with Android) is a hybrid Merge/Insertion sort, so Mergesort may in fact be used more than Quicksort considering the number of Android devices...