[SOLVED] CSE100 Lab1-Insertion-sort

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Lab01-u7l30y.zip (25.1 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
đź”’ Securely Powered by:
Secure Checkout
Rate this product

Description In the first lab assignment, your job is to implement insertion-sort (Yes, this is just a warm-up, and the labs will be increasingly difficult. So heads up!)

Input structure The input starts with an integer number which indicates the number of elements (integers) to be sorted, n. Then, the elements follow, one per line.

Output structure Recall that Insertion Sort first sorts the first two elements (in non-decreasing order), then the first three elements, and so on. You are asked to output the snapshot of the array at the end of each iteration. More precisely, for each 2 ≤k≤n, output the first k elements (in non-decreasing order) in a separate line where each element is followed by ;. A new line is followed by an enter.

Examples of input and output:

Input

6

5

3

2

1

6

4

Output

3;5;

2;3;5;

1;2;3;5;

1;2;3;5;6;

1;2;3;4;5;6;

More precisely, the above output example has 6 lines since a “cout << endl;” call was made at the end of each of the first 5 lines; those are the only white characters.

See the lab guidelines for submission/grading, etc., which can be found in Files/Labs.

  • Lab01-u7l30y.zip