Hey! I did not understand why to apply the top-to-bottom vs bottom-to-up approach. for e.g. why can't we apply bottom-to-top approach to:

f(n) = f(n-1) + f(n-2)

A beginner here.

Active In

Competitive Programming

UI/UX Design

Algorithms and Computer Programming

Machine Learning

Artificial Intelligence

Deep Learning

TED Talks

Reading

Featured Contributions

reply in this discussion

Hey! I did not understand why to apply the top-to-bottom vs bottom-to-up approach. for e.g. why can't we apply bottom-to-top approach to:

f(n) = f(n-1) + f(n-2)

A beginner here.

Read more… (30 words)

reply in this discussion

reply in this discussion

reply in this discussion

I am not able to find any problem in my code.please help.

int main(){int n,i;cin>>n;int a[n];for(i=1;i<=n;i++)cin>>a[i];//maximum nesting depthint max=0,count=0,pos=1;for(i=1;i<=n;i++){if(a[i]==1)count++;if(max<count){max=count;pos=i;}if(a[i]==2)count=0;}//maximum number of expressionsint num=0,exp=0,counter=0,position=1;for(i=1;i<=n;i++){if(a[i]==1){exp++;counter++;}if(a[i]==2){exp--;counter++;}if(exp==0){if(counter>num){num=counter;

Read more… (12 words)

reply in this discussion

In reference to Topcoder article it is given:

nlogn+1000047n = theta(nlogn)

This would mean nlogn+1000047n has same order of growth as nlogn.

But, the term n has a coffecient of 10^6 which cannot be ignored. So how is the order of growth of the term on left and right be equal???

Read more… (51 words)