Introduction
- In this blog, I am going to explain how to insert the sort. It is a simple sorting algorithm, which is relatively efficient for a small list.
- Compared to Bubble sort, Insertion sort is more efficient, though it has more constraints.
Software Requirements
- Turbo C++ or C.
Programming
- #include < stdio.h >
- int main()
- {
- int n, array[1000], c, d, t;
- printf("Enter number of elements\n");
- scanf("%d", & n);
- printf("Enter %d integers\n", n);
- for (c = 0; c < n; c++)
- {
- scanf("%d", & array[c]);
- }
- for (c = 1; c <= n - 1; c++)
- {
- d = c;
- while (d > 0 && array[d] < array[d - 1])
- {
- t = array[d];
- array[d] = array[d - 1];
- array[d - 1] = t;
- d--;
- }
- }
- printf("Sorted list in ascending order:\n");
- for (c = 0; c <= n - 1; c++)
- {
- printf("%d\n", array[c]);
- }
- return 0;
- }
Explanation
- In the programming mentioned above, it is clearly understood that it can be arranged in an ascending order and it can be more efficient compared to Bubble sort.


Output

Conclusion: Thus, it can be executed and printed successfully.

Conclusion: Thus, it can be executed and printed successfully.

SubashPosted Sep 15, 2016, 7:28 AM
Good one shobana
Vignesh ManiPosted Jul 20, 2016, 11:14 AM
Nice one
Anna GarlandPosted Jul 19, 2016, 1:40 PM
Good article
kalu singh raoPosted Jul 19, 2016, 9:48 AM
Nice...
Anu VPosted Jul 19, 2016, 8:17 AM
Nice