need help in this MCQ of this data structure and algorithm question with some explanation. ALGO1(A)// A is an integer array, index that starting at 1 1): for i=1 to n-1 do 2): minIndex = findSmallest(A,i) 3): exchange A[i] with A[minIndex] The sub-routine findSmallest(A,i) in Line 2, returns the index of the smallest element in the sub-array A[i:n] Suppose the array below is provided as input to ALGO1 2 5 6 7 3 8 1 4 Which function best describes the worst-case running time behaviour of ALGO1 on an array of size n? Option A) a*(n^2) + b*n +c, where a,b,c are constants Option B) a*n + b , where a and b are constants Option C) a * n * log(n) + b, where a,b are constants Option D) a*(n^3) + b*(n^2) + c*n + d, where a,b,c,d are constants.
I need help in this MCQ of this data structure and
ALGO1(A)// A is an integer array, index that starting at 1
1): for i=1 to n-1 do
2): minIndex = findSmallest(A,i)
3): exchange A[i] with A[minIndex]
The sub-routine findSmallest(A,i) in Line 2, returns the index of the smallest element in the sub-array A[i:n]
Suppose the array below is provided as input to ALGO1
2 | 5 | 6 | 7 | 3 | 8 | 1 | 4 |
Which function best describes the worst-case running time behaviour of ALGO1 on an array of size n?
Option A) a*(n^2) + b*n +c, where a,b,c are constants
Option B) a*n + b , where a and b are constants
Option C) a * n * log(n) + b, where a,b are constants
Option D) a*(n^3) + b*(n^2) + c*n + d, where a,b,c,d are constants.
Step by step
Solved in 3 steps