Consider the following algorithm pseudocode:
Algorithm Mystery(A[0..n-1,0..n-1])
Input: an n x n array A of integer numbers
Output: a boolean value
1. for(i=0; i< n-1; i++)
2. for(j=i+1;j< n;j++)
3. if A[i,j]!=A[j,i]
4. return false
5. return true
Note: dans votre estimation Grand O, donner la meilleure valeur possible. Par exemple, si vous prouvez que f(n) est O(n) et aussi que f(n) est O(n^2), alors la meilleure complexité est O(n).
Note: when giving the big-Oh, give the tightest upper bound possible. For example, if you can prove that f(n) is O(n) and that f(n) is O(n^2), choose the tighter upper bound, i.e. f(n) is O(n).
a) (2 pts)
Donner la complexité en temps d'exécution T(n) au pire cas de cet algorithme pour une matrice de dimension n x n. Justifier votre réponse.
Give a big-Oh for T(n) the worst-case running time of this algorithm for an input matrix of size n x n. Explain how you obtained this worst case.
b) 2 pts
Donner la complexité en temps d'exécution B(n) au meilleur cas de cet algorithme pour une matrice de dimension n x n. Justifier votre réponse.
Give a big-Oh for B(n) the best-case running time of this algorithm for an input matrix of size n x n. Explain the type of inputs (sample inputs) that will give this best case.