since your input is of fixed size, your algorithm always runs in constant time. If the # of students and # of courses are variable, the algorithm is O(n^2).
satya. On 5/28/07, sl7fat <[EMAIL PROTECTED]> wrote: > > hi i have an algorthim code and i have to find the time complixcity of > the code so can you plz help me ASAP the code is written done ,, > # include <iostream.h> > > void main() > { > > int a[10][4]= > {{ 16,17,19,13}, > {18,14,15,19}, > {18,20,20,19}, > {13,14,15,10}, > {20,17,19,19}, > {18,13,18,19}, > {18,10,15,12}, > {12,14,15,11}, > {12,16,17,18}, > {18,11,15,10}} ; > > > int i,j,max,min; > float avg,sum; > > > for(i=0;i<10;i++) > { > > for(j=0;j<4;j++) > { > > cout << a[i][j] << " "; > } > cout << "\n"; > } > > for(i=0;i<4;i++) > { > max= a[0][i]; > min= a[0][i]; > sum=0; > > for(j=1;j<10;j++) > { > > sum= sum+a[j][i]; > if(a[j][i]>max) > max=a[j][i]; > > if(a[j][i]<min) > min=a[j][i]; > } > > avg= sum/10; > > cout << "The average Grade for Exam "<<i+1<< " is: "<< > avg<<"\n"; > cout << "The minimum Grade for Exam "<<i+1<< " is: "<< > min<<"\n"; > cout << "The maximum Grade for Exam "<<i+1<< " is: "<< > max<<"\n\n"; > > > } > > for(i=0;i<10;i++) > { > min= a[i][0]; > sum=0; > for(j=0;j<4;j++) > { > sum= sum+a[i][j]; > if ( min>a[i][j]) > min= a[i][j]; > > } > sum= sum-min; > > cout << " The summation of the best 3 grades for student No > "<< i > +1<< " is: "<< sum<<"\n"; > } > > } > > thanx alot :D > > > > > -- ...what's remarkable, is that atoms have assembled into entities which are somehow able to ponder their origins. -- http://cs.uic.edu/~spopuri --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---