Question
1. what is the Big-O performance of the following function? def sum(n): k = 0 for i in range(n): for j in range(n): k =
1. what is the Big-O performance of the following function? def sum(n): k = 0 for i in range(n): for j in range(n): k = k + n return k
a. O(1) b. O(n) c.O(n2) d.O(log n)
2. what is the Big-O performance of the following function? def sum2(n): i = n k = 0 while i > 0: k = k + 1 i = i // 2 return k
a. O(1) b. O(n) c.O(n2) d.O(log n)
3. what is the Big-O performance of the following function? def sum(n): k = 0 j = 0 while k < n: k = k + 1 while j < n: j = j + 1 k = k + j return k
a. O(1) b. O(n) c.O(n2) d.O(log n)
4. what is the Big-O performance of the following function? def sum3(n): k = 0 for i in range (n): k = k + i for j in range (n): k = k - j return k
a. O(1) b. O(n) c.O(n2) d.O(log n)
5.what is the Big-O performance of the following function? def sum3(n): k = 0 for i in range (n): k = k + i return k
a. O(1) b. O(n) c.O(n2) d.O(log n)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started