Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C program required. You are asked to write a program to perform quicksort on an array of strings in the ascending lexicographical order (i.e. ASCII
C program required.
You are asked to write a program to perform quicksort on an array of strings in the ascending lexicographical order (i.e. ASCII code). You should select the pivot as the median of the first, middle and last element. In addition, you need to hide the pivot at the first position of the array in its iteration. Output the whole array after each partition. You can safely assume that all strings are distinct and contain no spaces, and the length of a stringis 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-q3.c". Input file: First line, n, an integer describes the length of the array. Second line, n distinct strings, the unsorted array. Output file: k lines, k is the number of partition steps. Each line should have exactly n strings separated by a space, indicating the result of the partition. Then, print an empty line. Then, output exactly n strings separated by a space, the result of quicksort. Sample Input: 4 Apple Orange Banana Pear Sample Output: Banana Apple Orange Pear Apple Banana Orange PearStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started