Модуль: Calculation of asymptotic complexity


Задача

4/9

Calculation of asymptotics - 4

Задача

For the code below, find the asymptotics: int n, m; cin>> n>> m; vector arr(n), sums; for (int i = 0; i < n; i++) cin>> arr[i]; for (int i = 0; i < n; i += m) { int sum = 0; for (int j = 0; j < m; j++) { if (i + j >= n) break; sum += arr[i + j]; } sums.push_back(sum); }
1) O(m)
2) O(n)
3) O(n+m)
4) O(nm)

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

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