subject

Consider the following pseudocode for a sorting algorithm, for 0 < α < 1 and n > 1.
badsort( - 1])
if (n = 2) and (a[0] > a[1])
swap a[0] and a[1]
else if (n > 2)
m = [α . n]
badsort( – 1])
badsort(a[n – – 1])
badsort( – 1])
1. implement badstoogesort from pseudocode to sort an array of integers. the value of α should be an input parameter to your program.
2. 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.
3. 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, 1, 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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:50
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: a. double the number. b. reverse the digits of the number. c. raise the number to the power of 2, 3, or 4. d. sum the digits of the number. e. if the number is a two-digit number, then raise the first digit to the power of the second digit. f. if the number is a three-digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit. after performing an operation if the number is less than 10, add 10 to the number. also, after each operation determine if the number is prime. each successive operation should be performed on the number generated by the last operation. your program should not contain any global variables and each of these operations must be implemented by a separate function. also, your program should be menu driven. 7. (fraction calculator) write a program that
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
You know the right answer?
Consider the following pseudocode for a sorting algorithm, for 0 < α < 1 and n > 1.
Questions
question
Mathematics, 22.04.2020 23:57
question
Mathematics, 22.04.2020 23:57
Questions on the website: 13722362