Consider the algorithm in below. Use it to answer the ques…
Consider the algorithm in below. Use it to answer the questions (a) to (d) below. template void BubbleSort(vector & toSort){ int len = toSort.size(); for (int i = 0; i < len; i++) { for (int j = 0; j < len - 1; j++) { if (toSort[j] > toSort[j + 1]) { T temp = toSort[j]; toSort[j] = toSort[j + 1]; toSort[j + 1] = temp; } } }} (a) (5 pts) Describe the best-case scenario for this algorithm. (b) (5 pts) Describe the worst-case scenario for this algorithm. (c) (10 pts) Find the exact worst-case time-complexity of this algorithm. (d) (5 pts) Find the asymptotic worst-case time-complexity of this algorithm, and classify it as logarithmic, polynomial, exponential, etc. as appropriate.
Read Details