Question: Sporting Consider the following variant of bubble sort: The function is intended to sort the array in ascending order and to run in time O(n),

 Sporting Consider the following variant of bubble sort: The function is

Sporting

intended to sort the array in ascending order and to run in

Consider the following variant of bubble sort: The function is intended to sort the array in ascending order and to run in time O(n), but there is a bug in the function. i. On the code above, show where the bug is and how to fix it. Your goal is to make a single change in the code such that the function sorts the array in ascending order and runs in time O(n); you do not need to try to do other improvements. ii. Then, indicate what will go wrong if we don't fix the bug, by choosing one of the following answers. Assume that the input array a has at least one duplicate value (a value that occurs two or more times in the array). Circle one answer below. The function runs in time O(n) The function sorts the array in descending order rather than ascending order. The function never terminates. The function stops before the array is sorted. The function is not stable. Consider the following variant of bubble sort: The function is intended to sort the array in ascending order and to run in time O(n), but there is a bug in the function. i. On the code above, show where the bug is and how to fix it. Your goal is to make a single change in the code such that the function sorts the array in ascending order and runs in time O(n); you do not need to try to do other improvements. ii. Then, indicate what will go wrong if we don't fix the bug, by choosing one of the following answers. Assume that the input array a has at least one duplicate value (a value that occurs two or more times in the array). Circle one answer below. The function runs in time O(n) The function sorts the array in descending order rather than ascending order. The function never terminates. The function stops before the array is sorted. The function is not stable. Consider the following variant of bubble sort: The function is intended to sort the array in ascending order and to run in time O(n), but there is a bug in the function. i. On the code above, show where the bug is and how to fix it. Your goal is to make a single change in the code such that the function sorts the array in ascending order and runs in time O(n); you do not need to try to do other improvements. ii. Then, indicate what will go wrong if we don't fix the bug, by choosing one of the following answers. Assume that the input array a has at least one duplicate value (a value that occurs two or more times in the array). Circle one answer below. The function runs in time O(n) The function sorts the array in descending order rather than ascending order. The function never terminates. The function stops before the array is sorted. The function is not stable. Consider the following variant of bubble sort: The function is intended to sort the array in ascending order and to run in time O(n), but there is a bug in the function. i. On the code above, show where the bug is and how to fix it. Your goal is to make a single change in the code such that the function sorts the array in ascending order and runs in time O(n); you do not need to try to do other improvements. ii. Then, indicate what will go wrong if we don't fix the bug, by choosing one of the following answers. Assume that the input array a has at least one duplicate value (a value that occurs two or more times in the array). Circle one answer below. The function runs in time O(n) The function sorts the array in descending order rather than ascending order. The function never terminates. The function stops before the array is sorted. The function is not stable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!