Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language C++. Write two short programs that implement the Quicksort and Merge Sort algorithms. Each of these programs will read up to 1000 integers, sort

Language C++. Write two short programs that implement the Quicksort and Merge Sort algorithms. Each of these programs will read up to 1000 integers, sort them, and then print them in a formatted fashion. Each program you write should read from standard input using input redirection. Input files for this assignment will contain a series of integers separated by whitespace. The data files are named random6.txt, random8.txt, random16.txt, etc., with the numeric part of the file name specifying the number of random values that the file contains. 1. Files You Must Write quick_sort.cpp - This file should contain your solution that uses the quicksort algorithm. merge_sort.cpp - This file should contain your solution that uses the merge sort algorithm. The two files will obviously contain a great deal of identical code. 2. Output - The output should print 8 sorted numbers per line (of course the last line may have less than 8 numbers), nicely aligned in columns. Numbers should be right-aligned. Use the setw manipulator to print numbers with a width of 8 characters, padded with leading spaces. Print a newline character ( ) at the end of each line. The output should look like this:

123456@uring:~/$ ./quick_sort < random6.txt 19 61 75 88 90 98 123456@uring:~/$ 123456@uring:~/$ ./merge_sort < random16.txt 7 15 15 20 30 37 42 52 53 56 58 63 65 74 78 89 123456@uring:~/$ 123456@uring:~/$ ./quick_sort < random25.txt 1 23 106 127 147 148 157 208 239 265 282 483 561 576 579 677 753 853 879 911 945 959 965 978 982 123456@uring:~/$ Note that your programs must always supply a newline character at the end of each line, even if the last line does not contain 8 numbers. In other words, after running your program, the Unix prompt must always appear in the leftmost column of the screen. Output that looks like this is incorrect:

123456@uring:~/$ ./quick_sort < random6.txt 19 61 75 88 90 98z123456@uring:~/$

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago