Home / Expert Answers / Computer Science / using-replit-i-need-to-test-5-common-sorting-algorithms-in-a-c-program-code-is-listed-in-the-attach-pa299

(Solved): Using Replit I need to test 5 common sorting algorithms in a C program. Code is listed in the attach ...



Using Replit I need to test 5 common sorting algorithms in a C program. Code is listed in the attached. Also need information for readme.txt file.

You are provided with a C program that implements and tests 5 common sorting algorithms. The sorting algorithms themselves have been removed. You are required to re-implement them so the program works.

You will implement four sort algorithms from the lecture/readings. Implement the algorithms as described in the lecture or your will not receive full credit.

The following files are provided:

  • main.c containing the main program. DO NOT EDIT THIS FILE
  • sortTests.c a file containing tests to verify the sorts work correctly. DO NOT EDIT THIS FILE
  • sortTests.h The function prototypes for the sorting tests. DO NOT EDIT THIS FILE
  • sort.h The function prototypes for the sort functions. You may add to this file but not remove/edit anything provided.
  • sort.c The sort functions are implemented here. You will make changes to this file

The sort.c file has one remaining sort called Gnome Sort. It is provided as an example. You will implement Insertion Sort, Bubble Sort, Merge Sort, and Quick Sort in this file.

Example Execution

You can run the code and it will provide a menu. You can collect timings or test one of the sorts.

If one of your algorithms fails, information about what went wrong will be printed.

Example 1

               Select Which Test to Run:

               0.) Time All Algorithms

               1.) Test Bubble Sort

               2.) Test Insertion Sort

               3.) Test Merge Sort

               4.) Test Quick Sort

               5.) Test Gnome Sort

               1

               Testing Bubble Sort

               Enter Size of Arrays to Test:

               10

               Enter Number of Tests to Run:

               15

               Passed 15 out of 15 tests.

Example 2

               Select Which Test to Run:

               0.) Time All Algorithms

               1.) Test Bubble Sort

               2.) Test Insertion Sort

               3.) Test Merge Sort

               4.) Test Quick Sort

               5.) Test Gnome Sort

               3

               Testing Merge Sort

               Enter Size of Arrays to Test:

               7

               Enter Number of Tests to Run:

               9

               Passed 9 out of 9 tests.

Example 3

               Select Which Test to Run:

               0.) Time All Algorithms

               1.) Test Bubble Sort

               2.) Test Insertion Sort

               3.) Test Merge Sort

               4.) Test Quick Sort

               5.) Test Gnome Sort

               5

               Testing Gnome Sort

               Enter Size of Arrays to Test:

               10

               Enter Number of Tests to Run:

               100

               Passed 100 out of 100 tests.

Timings

Once All your algorithms work correctly, run the program and select 0 to collect timings.

Place the output of the program in a file readme.txt

Below the timings answer the following questions:

  1. What was the fastest algorithm?
  2. What was the slowest algorithm?
  3. Did the timings match the analysis from class?
  4. What was the hardest part of this assignment?

Template Table

Size

Gnome

Bubble

Insert

Merge

Quick

8

?

?

?

?

?

16

?

?

?

?

?

32

?

?

?

?

?

64

?

?

?

?

?

128

?

?

?

?

?

256

?

?

?

?

?

512

?

?

?

?

?

1024

?

?

?

?

?

2048

?

?

?

?

?

4096

?

?

?

?

?

8192

?

?

?

?

?

16384

?

?

?

?

?

32768

?

?

?

?

?

65536

?

?

?

?

?

131072

?

?

?

?

?




 

 



We have an Answer from Expert

View Expert Answer

Expert Answer


Source code: package cheggapps; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author D
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe