Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CTS-277 Data Structures and Algor i thms Review: Analysis of Algorithms 1. One w

ID: 3882639 • Letter: C

Question



CTS-277 Data Structures and Algor i thms Review: Analysis of Algorithms 1. One way to determine the execution speed of an algorithm is to implement it in a programming language, execute the program, and directly measure the actual time it takes to complete. Briefly explain the possible problem(s) with this approach. 2 For each of the following code segments: -identify the statoments that are "mice" - identify the Big-o run-time (show how you arrived at the answer) sum sqr o for ( ct 0; ct size: ++ ct ) , sum-sar += data [ct] * data [ct]; mean sqr sum_sqr size: b.1 sum=0; for( ct 1: ct sizei ++ct sum += ct; product = 1 ; for( ct = 1; ct = size; ++ct ) product ct: difference = product - sum; C. i max = datato, o); for( ctr = 0; ctr : n; ++ctr ) for( ctc = 0: ctc

Explanation / Answer

2.
a) O(size)
b) O(size)
c) O(n^2)
d) O(1)
e) O(n)
f) O(n^2)
g) O(size)
h) O(size^2)
i) O(size)
j) O(n^2)
k) O(n)
l) O(n^2)
4.
a) O(n)
0.004 seconds at n=200
for n=4000; expected time = 0.004 * 20 = 0.08 seconds
b) O(n^2)
0.004 seconds at n=200
for n = 4000; expected time = 0.004 *4000* 4000/ 40000 = 0.004*400 = 1.6 seconds

8.
a) O(n)
b) O(n^2)
c) O(n)