Posts Tagged ‘algorithms’

Some More about Recursion

Written by Raza. Posted in C++

recursion in programming

 

Deviating a little from our series of discussion on Sorting Algorithms, this time and maybe the next one too, we would be plunging into certain other core concepts considered vital and important to good programming. Last time, we carried out the Selection Sort using the recursive technique. As recursion is a tricky and fundamental topic and a very powerful tool as well, we would be having some more discussion on recursion now.

Binary Search Algorithm in C++

Written by Raza. Posted in C++

Binary Search Algorithm C++

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. 

The Insertion Sort Algorithm

Written by Raza. Posted in C++

The Insertion Sort Algorithm

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.

The Basic Searching Algorithm: Linear Search

Written by Raza. Posted in C++

linear search algorithm

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. 

Example and Source Code for Quick Sort

Written by Raza. Posted in C++

pivot value of list in quick sort

In the previous post I elaborated on Quick Sort and its basic principles, recursive technique, how to select the pivot and the comparison of quick sort and bubble sort. Today I shall explain a sample problem step by step and then write a source code for it. As I mentioned, I would be considering the first element of the list as the pivot. Watch for the next paragraphs for step by step procedure and source code.