Question: Consider the following algorithm ALGORITHM Mystery ( n ) S 0 for i 1 to n do S S + i * i Return S
Consider the following algorithm
ALGORITHM Mystery n
S
for i to n do
S S ii
Return S
What does the algorithm computes?
Write the running time for each line, and derive the exact time?
What is the basic operation?
What is the efficiency class of this algorithm?
Can we do better algorithm?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
