Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3: Quicksort (30%) (using C programming) You are asked to write a program to perform quicksort on an array of strings in the ascending

Question 3: Quicksort (30%) (using C programming)

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 Pear 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago

Question

4. EMC Corporation

Answered: 1 week ago

Question

6. Vanguard

Answered: 1 week ago