How many floating point operations are needed to generate a vector using a for-loop:
for ("0 to n")
v = element(i+1)
each element in the vector is : 1/(i^2)
Also, how many floating point ops are needed to sum all the elements in a vector using a for loop?
looks something like:
for(0 to n)
sum = sum+i
Is this correct?
Generating a vector: O(constant)
Sum the vector elements: O(n) or exactly (n-1)
If you filling a vector with values in a loop by "generating", then it is also O(n)
As for summing, why is it O(n-1)? It is also O(n).