C++
Control structures form the basic entities of a structured programming language. We all
know languages like C/C++ or Java are all structured programming languages. Control
structures are used to alter the flow of execution of the program. Why do we need to alter
the program flow ? The reason is decision making! In life, we may be given with a set of
option like doing Electronics or Computer science. We do make a decision by analyzing
certain conditions (like our personal interest, scope of job opportunities etc). With the
decision we make, we alter the flow of our lifes direction.
Read More
We have seen 3 simple sorting algorithms already 1) Bubble Sorting 2) Selection Sorting and
finally Insertion sorting. All these algorithms were so simple to understand and were easy to
implement as a program in C/C++ or even Java. But at the same time all 3 of them were too
inefficient. Their execution time was of the order of n*n, where n is the number of elements
to be sorted. In practice, these simple sorting algorithms are seldom used. Quick sort is an
improved sorting algorithm developed by Tony Hoare (C.A.R Hoare) in 1960, at the age of
26, while
Read More
So far we have seen 2 sorting algorithms:- 1) Bubble sorting and 2) Selection sorting. Now in
this article, we are analyzing insertion sort algorithm with its example code suitable for
C/C++/Java programming languages. I recommend you go through above articles of Bubble
sorting and Selection sorting before reading further. Insertion sorting algorithm sorts one
element at a time. It begins by sorting the first 2 elements in order. In the next step, it takes
the third element and compares it against the first two sorted elements. Exchanges are
made if necessary and the 3 elements will be sorted with respect to
Read More
invention of computer, many approaches and methods have been tried to write a program.
It includes methods like a) Top-Down programming b) Bottom-Up programming c)
Modular programming d) Structured programming etc. The basic purpose or the basic aim
of all these methods were same to
Read More