Linear search, as described last time is ineffective for method for finding piece of information, the key from a large list. If you have a database of one hundred thousand people living in Los Angeles, you would surely have a headache if you were to look at each and every element of that database to look for your key. In such situations, Binary Search comes into play. Binary search is a very efficient searching algorithm especially for large amount of data. For binary search to perform, data in the list has to be sorted beforehand.
Over the month, we have been inching towards more efficient sorting techniques. Insertion Sort is yet another Sorting Algorithm which works on the principle of In-place sorting. It is the most efficient Sorting Algorithm for small Lists but not very good when the size becomes increasingly large. You would be surprised to hear that Insertion sort uses Bubble Sort in its complete procedure as well. So let us see and try to understand its basics.
A technique quite frequently employed in Object Oriented Paradigm and otherwise is known as Generic Programming. Generic Programming is a concept using which you a user can write a code which works well for many data types. In other words, it is type independent programming. A function made generic does not need to know what kind of data type it is receiving. Generic programming is made possible through a feature known as templates. Templates allow functions and classes to operate with these generic or types. I shall explain you why we need templates and how do we employ them.
We search for different sort of things in our daily life. This search process is so common and typical that we do not realize how actually search is being performed. And that how the required key is brought out from the depth of information of the massive databases. In computer science, there are many methods for searching a key inside a list. Just like various sorting techniques, there are many searching algorithms as well. A basic and primitive searching method is to look at every element of the list and match the required information. This is known as Linear Search. I shall explain to you what linear search in essence is.