Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Implement badStoogeSort from pseudocode to sort an array of integers. The value of should be an input parameter to your program. Implement the

Using C++

image text in transcribed

Implement badStoogeSort from pseudocode to sort an array of integers. The value of should be an input parameter to your program. Implement the algorithm in C/C++. Your program should be able to read inputs from a file called data.txt, where the first value of each line is the number of integers that need to be sorted, followed by the integers. The output will be written to a file called bad.out. Then, Modify the code to collect running time data. Call the new timing program badStoogeSort. Instead of reading arrays from the file data.txt and sorting, you will now generate arrays of size n containing random integer values from 0 to 10,000 to sort. Use the system clock to record the running times of each algorithm for n = 5000, 10000, 15000, 20,000, .... for two values of = 2/3 and = 3/4. You may need to modify the values of n if an algorithm runs too fast or too slow

Consider the following pseudocode for a sorting algorithm, for 0 1. badSort(A[O...n - 1]) if (n = 2) and (A[0] > A[1]) swap A[0] and A[1] else if (n > 2) m = fa.nl badSort(A[O...m 1]) badSort(A[n m...n 1]) badSort(A[O...m 1])

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

Students also viewed these Databases questions

Question

b. Where did they come from?

Answered: 1 week ago