Are you familiar with the Standard 52-card deck game? You must be knowing that the rank of a particular card depends on the value written on the card itself(Note: The card containg value "A" has highest rank). Will you be able to sort the given messed up cards by their values so that the rank of the cards will be in ascending order? Give it a try. Click on the cards to add them to right box.
Well! pretty easy. Wasn't it? But will you be able to sort the cards if the values won't be given to you? Come on Give it a try
Solved it? Not that difficult. Isn't it? Good job. But are you able to figure out that, what was your approach to sort the cards in the 2nd time? Here we considered the approach of insertion sort, which is an efficient algorithm for sorting a small number of elements. Insertion sort works the way many people sort a hand of playing cards. We start with an empty right box (yellow) and the cards face down on the left box (red). We then add one card at a time from the left box and insert it into the correct position in the right box. To find the correct position for a card, we compare it with each of the cards already in the right box, from left to right, as illustrated in the given problem, all times, the cards held in the right box are sorted.