







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








CS260 Data Structures
Galen Long
Summer 2024-
Prove each of the following bounds: a. 5 n^2 + 11 n^3 − 4 = Θ( n^3 ) b. 12 n + 7 = ω (
n ) c. log 2 n = O ( n ) ▶ (^) L’Hôpital’s rule: lim n →∞ f g^ (( nn )) = lim n →∞ f g^ ′′(( nn )) ▶ (^) Derivative of log 2 n = (^) ln 12 ∗ n
b. 12 n + 7 = ω (
n )
n lim→∞
12 n + 7 √ n = (^) n lim→∞ 12
n +
n = ∞ + 0 = ∞
(Remember that x^ a x b^ =^ x^
a − b (^) , √ x = x 0_._ (^5) , and x = x (^1) ).
c. log 2 n = O ( n ) Using L’Hôpital’s rule:
n^ lim→∞
log 2 n n
= (^) n lim→∞
= (^) n lim→∞
1 ln 2 ∗ n 1 = (^) n lim→∞
ln 2 n = 0
Proving a little-o bound also proves a big-O bound.
function series() { sum = 0 for (i=0; i<100; i++) { sum += i } return sum } ∑^99
i = 0
c = 100 c = O ( 1 )
Model the runtime of the following function using summation(s) (if needed): // A, B are arrays of n integers function sumBoth(A, B, n) { sum = 0 for (i=0; i
Model the runtime of the following function using summation(s) (if needed): function min(a, b, c) { // a, b, c are integers if (a < b) { if (a < c) { return a } else if (c < b) { return c } else { return b } } else { if (b < c) { return b } else if (c < a) { return c } else { return a } } } Simplify to a closed form and give a tight upper bound on the runtime.
function min(a, b, c) { // a, b, c are integers if (a < b) { if (a < c) { return a } else if (c < b) { return c } else { return b } } else { if (b < c) { return b } else if (c < a) { return c } else { return a } } } This function has no loops and only performs a constant number of operations. It runs in O ( 1 ) time.
// n is an integer function weird(n) { x = 0 for (i=n; i>=1; i--) { for (j=1; j<=i; j++) { x = x - i * j } for (k=0; k