Какова нотация big-O следующего алгоритма
Q1. What is the Big-O notation of the following algorithm (assume that all variables have been declared): for (int i=1; i<= n; i++) sum = sum + i * (i + 1); Q2. What is the Big-O notation of the following algorithm (assume that all variables have been declared): for (int i = 5; i <= 2 * n; i++) System.out.println(2 * n + i - 1); Q3. What is the Big-O notation of the following algorithm: for (int i = 1; i <= 2 * n; i++) for (int j = 1; j <= n; j++) System.out.println(2 * i + j); System.out.println(“ “); Q4. What is the Big-O notation of the following algorithm: for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) System.out.println(i + j + k); Q5. Each of the following expressions represents the number of inputs for certain algorithms. Write them in Big O notation (e.g, n + 2 -> O(n)): - n2 + 6n + 4 - 5n3 + 2n + 8 - (n2 + 1)(3n + 5) - 5(6n + 4) - n + 2log2n - 6 - 4nlog2n + 3n + 8
Что я уже пробовал:
What is the Big-O notation of the following algorithm
Patrice T
Каковы ваши ответы ?