“Name any 2 algorithms that you use in you daily life!” .This was the question posed to me when I least expected it. Assuming it was some sort of an interactive session in progress I let my guard down and answered gaumlessly. Algorithms that I use daily? Well that’s a bummer! You see I am but human, and to top that I am a stupid human. Being stupid doesn’t really require me to use algorithms to get about my daily life I presumed. So I answered naively. I stated two algorithms off of the top of my head, in the hope that the attention gets diverted off of me and I can go back to being one of the many quiet spectators in class. But to my utter shock it didn’t end there, I was to come up with a full-fledged write-up about these two algorithms and how I apply it in real life. It then dawned upon me that I had walked right into the middle of a beautifully laid out trap. Hence this stochastically unusual, yet intriguing write-up on how I apply bubble sort and binary search algorithms in my day to day life.
It’s a simple algorithm used to sort an unsorted list of elements preferably in ascending order. The basic concept is we test every element with the succeeding one to check whether the element is in order or not. We repeat this process over the entire list as many times as the number of elements in the list.
One daily use of this algorithm? Well the answer is fairly simple. We have all been through this process throughout our childhood. Let me take you back to nostalgic memories of your physical education classes or sports classes back in school. Lined up in a random order in front of the teacher, who’s put to the task of lining you all up in an ascending order of height. The bubble sort algorithm comes in handy here. In this case every person’s height is an element of the list. With every pass that the teacher goes over the students, they slowly start standing in a more orderly fashion till all of them stand according to height.
This algorithm is used to find the location of an element in a sorted list. The technique is old and reliable. The method is to compare the middle element with the targeted value (key element), if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful or the remaining half is empty. This seems to be a quite effective method since it escapes the redundancy of going over every element and instead narrows down the searching range efficiently.
One practical application that hits me immediately when it comes to this algorithm is searching for a book in the library. Here our sorted list is the well-arranged books in an alphabetical order. Our target element is the book we prefer to read. Instead of hopelessly running around in circles and ruffling through every rack to find our book we can apply this algorithm to find that book without breaking a sweat. All we need to do is determine the total number of racks, then find the middle rack. If we don’t find the book, then we accordingly determine whether to omit the first half of the racks or the second half. We repeat this process till we finally find our book or run out of racks to look in.
We seem to use algorithms more often than we realise. It is an integral part of our life and is embedded deep within us and serves as an efficient problem solving instinct. This makes it evident that algorithms are not only needed by our computers but is indeed well knitted in various aspects of our daily life. Algorithms serve as recipes to a more convenient life.
Author – Sahana R
USN – 1CR15IS087