It's been a while since I reviewed my understanding of some of the fundamental sorting algorithms so I thought it would be fun to implement a few of them and compare their performance. In this post I have provided code demonstrating Selection Sort, Insertion Sort, Merge Sort and Quick Sort along with some unit tests to compare their performance for different input sizes.
Google Code Jam qualification round was just last weekend and although I didn't get time to participate on Saturday I did spend some time Sunday looking at the problems and having a go at solving them. I attempted two problems which were "Revenge of the Pancakes" and "Counting Sheep" and I've provided my solutions to these problems in this post.
The Java ternary operator is a way of saying a lot while writing a little. It's essentially a shorthand for if-then-else, and there are some clever ways of using it in your programs.