Question: Question 2 : Insertion Sort ( 3 0 % ) You are asked to write a program to perform insertion sort on an array of
Question : Insertion Sort 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 iiA is the smallest and z is the largest ieAaBbZz 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 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 labqc Input file: First line, n an integer describes the length of the array. Second line, n distinct words, the unsorted array. Output file: n lines, each line should have exactly n words separated by a space, indicating the result of each iteration in selection sort. Sample Input: 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
