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, 3:28 AM EDT
Good one shobana
Vignesh ManiTOP 100Posted Jul 20, 2016, 7:14 AM EDT
Nice one
Anna GarlandPosted Jul 19, 2016, 9:40 AM EDT
Good article
kalu singh raoPosted Jul 19, 2016, 5:48 AM EDT
Nice...
Anu VPosted Jul 19, 2016, 4:17 AM EDT
Nice