What is the running time of the following program?
int C, N, R0, R1, I;
void A(int R){ int I; for(I=1;I<=N;I++) R=R*I;}
void B(int R){ int I, J; J=1; for(I=1;I<=N;I++) { A(J); R=R*J; }}
void main(){ scanf("%d",&C); scanf("%d",&N); R0=1; R1=1; if(C=='#') for(I=1;I<=N;I++) B(N); A(N);}
Difficulty level
This exercise is mostly suitable for students
O(n^3)
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Game trees