15.7 Exercises, Problems, and Projects
15.7.1 Multiple Choice Exercises
-
1. What is the Big-Oh of this function:
T(n) = n2 - 2 n + 99
❑ O(n2)
❑ O(99)
❑ O(n)
❑ O(1)
-
2. What is the Big-Oh of this function:
T(n) = n3 + 10 n2 + 20 n + 30
❑ O(n3)
❑ O(n2)
❑ O(n)
❑ O(1)
-
3. What is the Big-Oh of this function:
T(n) = n2 + n * log n + 12 n + 5
❑ O(n * log n)
❑ O(n2)
❑ OO(n)
❑ O(1)
-
4. We have the following recurrence relation representing the running time of a function; what is the running time of that function?
T(n) = T(n - 1) + 1
❑ O(2n)
❑ O(n * log n)
❑ O(n2)
❑ O(n)
-
5. Which of these running times is the worst?
❑ O(n5)
❑ O(2n)
❑ O(n * log n)
❑ O(n)
-
6. Look at the following method:
public static int foo1
Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.