The first is
sum=0;
for (int i=n;i>=0;i++)
{
sum*=x;
sum+=a[i];
}
return sum
For this one I figured out f(n)=2(n+1)+1=2n+3 Does this seem correct?
The second one is even more trouble for me
sum=a[0]+a[1]*x;
for(int i =2; i<=n ; i++)
{
temp =x;
for (int j=2; j<= i ;j++)
{
temp*= x;
}
sum+= a[i] * temp;
}
this one has me REALLY confused
Is it basically a form of this in a way?
for(int i=0;i<=n;n++)
{
for(int j=0;j<=i;j++)
{
}
}
So would the big-o for this be??
Any help is greatly appreciated! Thanks.
This post has been edited by Ap0C552: 02 October 2011 - 12:46 PM

New Topic/Question
Reply



MultiQuote





|