Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELP ASAP PROBLEM 3 30 POINTS Design an algorithm to approximately sort a vector of real numbers in [0, 1] using the following approximation
PLEASE HELP ASAP
PROBLEM 3 30 POINTS Design an algorithm to approximately sort a vector of real numbers in [0, 1] using the following approximation criterion: if the difference between two numbers is less than a tolerance level 8, then the ordering of the two numbers does not matter. The tolerance level 8 is also in the range [0,1], where 8 = 0 denotes an exact sort. For example, if d = 0.005, then 0.451 and 0.454 can be sorted as 0.451,0.454 or 0.454, 0.451 since the difference between them is less than 8. Hint: start by considering a case with a large tolerance level, e.g. 8 = 0.1 so that the order of any two numbers within 0.1 of each other does not matter. How would you solve this problem? Then generalize to arbitrary 8 (0,1). a) Describe your algorithm using pseudocode. Compute the worst-case time complexity for your algorithm using big O notation as a function of the number of elements N and the tolerance level 8. State how your approximate sorting algorithm reduces computation time compared to an exact sorting algorithm. For full credit, design your algorithm to achieve the best possible worst-case big O time complexity. (20 points) b) Implement your algorithm as a C++ function with the following header: (10 points) void approxSort(std::vectorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started