Модуль: Calculation of asymptotic complexity


Задача

5/9

Calculation of asymptotics - 5

Задача

For the code below, find the asymptotics:
  int n, c; cin>> n>> c; vector arr(n); for (int i = 0; i < n; i++) cin>> arr[i]; int l = 0, r = c; while (r - l > 1) { int m = (l + r) / 2; int less = 0; for (int i = 0; i < n; i++) { if (arr[i] <m) less++; } if (less <= n / 2) l = m; else r = m; }
1) O(n + c)
2) O(nc)
3) O(c*log(n))
4) O(n*log(c))

Выберите правильный ответ, либо введите его в поле ввода

Комментарий учителя