Big O Notation Exercise
Question 1:
int findMax(int arr[], int n) // O(n)
{
int max = arr[0]; // O(1)
for (int i = 1; i < n; i++) // O(n)
{
if (arr[i] > max) // O(1)
max = arr[i];
}
return max;
}Analayzing the code:
Question 2:
Analayzing the code:
Question 3:
Analayzing the code:
Question 4:
Analayzing the code:
Last updated