I want to ask where I could find the advanced exercises or the book with exercises of algorithms optimizing and tracing for my students.
Sample:
Optimize algorithm:
t[0] = 0
for (n = 1; n <= N; n++)
sum = 0
for (i = 1; i <= n; i++)
sum += n-1 + t[i-1] + t[n-i]
t[n] = sum/n
Another sample:
Result of:
for(int i = 0; i < 10; i++)
{
Console.WriteLine((i + 1 + i) / i )
}
Loading
Ivan FrohlichPosted Mar 18, 2011, 10:18 PM
you can't devide by 0(exeption error).
as the first example:
won't be able to iterate on the loop if the N is unknown, so it can't validate n(n<=N), it's
like asking: Store in n integer 1 and then ask is one less or equal to unknown value.