Question: 5 . Consider the following pseudo - code for the BubbleSort algorithm and helper function Swap for answering the questions below. ( 1 0 pts

5. Consider the following pseudo-code for the BubbleSort algorithm and helper function Swap for answering the questions below. (10 pts total)
Function Swap(a, b):
Input: Two elements, a and b, of the same type.
Output: No direct output, but the values of a and b will be swapped upon completion.
ca
ab
bc
Algorithm BubbleSort(A):
Input: An array A of n comparable elements, indexed from 1 to n.
Output: An ordering of A so that its elements are in non-decreasing order.
for i1 to n 1, do:
for j1 to n I, do:
if A[j]> A[j +1], do:
Swap(A[j], A[j+1])
return A
5a. Identify the lower bound, upper bound, and tight bound (if possible) time complexity of the Swap function in terms of the input size, n, if applicable. If any of these time complexities differ, explain what kind of input results in each case. (5 pts)
\Omega Swap:
OSwap:
\Theta Swap:
5b. Identify the lower bound, upper bound, and tight bound (if possible) time complexity of the BubbleSort function above in terms of the input size, n, if applicable. If any of these time complexities differ, explain what kind of input results in each case. (5 pts)
\Omega BubbleSort:
OBubbleSort:
\Theta BubbleSort:

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!