Description
COP3530
Homework #1
Insertion Sort
In this assignment you have to implement the insertion sort algorithm. Your code should read N numbers and print them in sorted order.
INPUT:
On the first line you can read the quantity of numbers, N. On the following N lines you can read the numbers that are going to be sorted, one per each line.
OUTPUT:
Your code should print the sorted numbers in N lines, one per each line.
Sample input:
5
12
19
16
17
13
Sample output:
12
13
16
17
19
Notes
• Your code is going to be compiled with GCC. It’s your responsibility to make sure there are no compile errors. If your code generates compile errors you will receive no credit.
• Your code should follow the input and output format described above. Do not change the format of the input and do not print anything other than what’s described above. This means that your output should ONLY be the N lines containing the N numbers. (E.g. do not print “Please enter a number:” before reading a number).
• You should submit a single cpp file. Do not archive (i.e. zip/rar/tar) your source file.
• Your code is going to be tested against considerably big inputs, so be sure to implement the insertion sort algorithm correctly.
Reviews
There are no reviews yet.