Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

What is Insertion Sort in dfs (data file structure)?

  Shared By: Poppy Brown    Date: Jan 10    Category: C++ Programming    Views: 1914

Answer:

This sorting technique is very easy. In this, we sort the array taking into consideration the concept of insertion. If the first element is greater than the second, then we interchange them. Then we check the third element if it is smaller than the above elements then it is inserted at appropriate place.

Pass:

Initially the elements of the array are:
9 8 7 6 5 4 3 10 2 1

| 9 8 7 6 5 4 3 2 1 1 |
| 8 9 8 7 6 5 4 3 2 2 |
| 7 7 9 8 7 6 5 4 3 3 |
| 6 6 6 9 8 7 6 5 4 4 |
| 5 5 5 5 9 8 7 6 5 5 |
| 4 4 4 4 4 9 8 7 6 6 |
| 3 3 3 3 3 3 9 8 7 7 |
| 2 2 2 2 2 2 2 9 8 8 |
V 10101010101010109 9 V
1 1 1 1 1 1 1 1 1010

Share: 
 

Didn't find what you were looking for? Find more on What is Insertion Sort in dfs (data file structure)? Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: