Question 6:
Give a big - Oh characterization, in terms of n, of the running time of the following two algorithms:
ALGORITHM S1 ($$a_1,...,a_n$$)
total $$\leftarrow 0$$
for $$i \leftarrow 1$$ to n do
total $$\leftarrow total + a_i$$
$$i \leftarrow i + 2$$
return total
ALGORITHM S2 ($$a_1,...,a_m,b_1,...,b_n$$)
count $$\leftarrow 0$$
for $$i \leftarrow 1$$ to m do
total $$\leftarrow 0$$
for $$j \leftarrow 1$$ to m do
for $$k \leftarrow 1$$ to n do
total $$\leftarrow total + b_k$$
if total $$= a_i$$ then
count $$\leftarrow count + 1$$
return count