Question: Consider the following sorting algorithm for an Array A[1..n] : Algorithm 2: BubbleSort(A) for i:=1n do for j:=1ni do if A[i]>A[j] swap(A[i] 1. Give an
![Consider the following sorting algorithm for an Array A[1..n] : Algorithm](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66db2b94e681c_57266db2b9468b5b.jpg)
Consider the following sorting algorithm for an Array A[1..n] : Algorithm 2: BubbleSort(A) for i:=1n do for j:=1ni do if A[i]>A[j] swap(A[i] 1. Give an example execution of the algorithm. Use it to visualise yourself how the algorithm works. 2. Now show that the algorithm indeed sorts the array. 3. Analyse the algorithm's worst case running time. 4. What is the best-case running time of the algorithm? 5. Does the algorithm follow one of your already known design conepts? If yes, which one? 6. Find a simple way to improve/optimise the running time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
