Question: Consider the following algorithm: FUNCTION foo ( n ) s : = 0 FOR i : = 1 TO n DO s : = s

Consider the following algorithm:
FUNCTION foo( n )
s :=0
FOR i :=1 TO n DO
s := s + i * i
RETURN s
Analyse the algorithm and determine:
1. What is its basic operation?
2. How many times is the basic operation executed?
3. What is the eciency class of this algorithm?
4. What does this algorithm compute?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!