Insertion Sort

** **

**Objective:**

Write a program that takes in any user defined number values and then performs insertion sort resulting in an array of values in ascending order.

- First the user must input how many values they are entering
- Next the user enters that many values, which populates an array of the size previously entered.
- Using TWO arrays then perform insertion sort
- The first array stays unsorted
- The second array is sorted
- Pseudo-code for insertion sort

// a is the first array

for(index = 0; index < a.lenght; index++)

put the value of index a[index] into the second array in the correctly sorted position

(IE the values at a lower index are less than the value. The values at a higher index are greater than the value.)

- When inserting a number in the middle of the array all other numbers ahead of it must be shifted forward
- HINT start from the back and pull the values forward

- Print both the sorted and unsorted arrays

**Example Dialog:**

** **

**Welcome to the insertion sorter**

** **

**Please enter the number of values you would like to sort**

**6**

**Please enter the number at 0**

**5**

**Please enter the number at 1**

**6**

**Please enter the number at 2**

**8**

**Please enter the number at 3**

**7**

**Please enter the number at 4**

**4**

**Please enter the number at 5**

**1**

** **

**The unsorted array is**

**5 6 8 7 4 1**

**The sorted array is**

**1 4 5 6 7 8**

**Done!**

Subject | Computer |

Due By (Pacific Time) | 09/29/2014 11:29 pm |

Tutor | Rating |
---|---|

pallavi Chat Now! |
out of 1971 reviews More.. |

amosmm Chat Now! |
out of 766 reviews More.. |

PhyzKyd Chat Now! |
out of 1164 reviews More.. |

rajdeep77 Chat Now! |
out of 721 reviews More.. |

sctys Chat Now! |
out of 1600 reviews More.. |

sharadgreen Chat Now! |
out of 770 reviews More.. |

topnotcher Chat Now! |
out of 766 reviews More.. |

XXXIAO Chat Now! |
out of 680 reviews More.. |