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?
384
Upvotes
View all comments
Show parent comment
18
u/[deleted] Aug 14 '13 edited Aug 14 '13
If we're going to talk implementation then I'm pretty sure insertion sort is going to be quicker than bubblesort since you can keep the value to be inserted in a register. Bubblesort doesn't keep anything around for long so it's bad for caching. This is also the reason quicksort itself is fast, of course, keeping stuff in registers and having tight loops makes fast code. But these are implementation details and they distract from the beauty of algorithms.