Question: You are asked to write a program to perform insertion sort on an array of words in the ascending alphabetical order. The alphabetical order is

You are asked to write a program to perform insertion sort on an array of words in the
ascending alphabetical order. The alphabetical order is defined as (i) capital letter is smaller
than its small letter, and (ii)A is the smallest and z is the largest (i.e.A<a<B<b<...
<Z<z). Output the whole array after each iteration. You can safely assume that all strings
are distinct and contain no spaces, and the length of a word is at most 100.
Your program should read the input from the file, and output the answer to another file. The
first argument is the input file name, while the second argument is the output file name.
Name your program as lab2-q2.c.
Input file: First line, n, an integer describes the length of the array. Second line, n distinct
words, the unsorted array.
Output file: n-1 lines, each line should have exactly n words separated by a space, indicating
the result of each iteration in selection sort.
Sample Input:
4
Apple Orange Banana Pear
Sample Output:
Apple Orange Banana Pear
Apple Banana Orange Pear
Apple Banana Orange Pear

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!