Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program called performance .cpp that displays the performance of three different sorting algorithms (selection sort, insertion sort, and quick sort) on the

Write a C++ program called performance.cpp that displays the performance of three different sorting algorithms (selection sort, insertion sort, and quick sort) on the screen.

Your program should read the input size (= number of input data) from a user and generate the input data (= positive integer numbers) based on the users selection (= numbers in the ascending order, numbers in the descending order, or numbers in the random order). Your program can generate any positive numbers. However, you have to generate the numbers in the correct order (= ascending, descending, or random) to meet the users choice. For the homework, your program should save the input data to a file named input.txt on the clould9 so that you can check the content of the input data later when you finish the execution. We will also check the file content when we grade as well.

Once your program generates the input data, it should conduct the sorting algorithms for the input file and display execution time information (= start time, end time, and elapsed time) for each sorting algorithm. In the problem, you should use dynamic memory to hold a big input size such as 10,000, 50,000 or more.

-------------------------> This is a sample result of the C++ program on the cloud9: <----------------------------------

$ g++ -o performance performance.cpp

$ ./performance

Enter input size: 350

========== Select Order of Input Numbers ==========

1. Ascending Order

2. Descending Order

3. Random Order

Choose order: 1

============================================================

Generate input data in ascending order . . .

Done.

============================================================

============================================================

Selection sort performance

Starting time: 2018-3-29 23:04:39

Ending time: 2018-3-29 23:04:40

Elapsed time: 1.40925 seconds

============================================================

============================================================

Insertion sort performance

Starting time: 2018-3-29 23:04:41

Ending time: 2018-3-29 23:04:41

Elapsed time: 0.21503 seconds

============================================================

============================================================

Quicksort performance

Starting time: 2018-3-29 23:04:42

Ending time: 2018-3-29 23:04:43

Elapsed time: 1.477957 seconds

============================================================

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions