Complexity of a C++ source code
Hello. ANybody can tell me how can i calculate the complexity of the following source? thanks in advance..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
t1=clock();
int g,count;
int line[v];
for (int zmn=0;zmn<5000000;zmn++)
{
for (i=0;i<v;i++)
{
count[i]=v+1;
}
count[0]=0;
for (i=0;i<v;i++)
{
array[i][0]=32769;
}
j=0;i=0;n=0;g=0;int s=0;count=0;
for (m=0;m<v;m++)
{
int control=0;k=32768;
while (i<v)
{
for (s=0;s<v;s++)
{
if (line[s]==v+1){break;}
if (array[line[s]][j]<k)
{
k=array[line[s]][j];control=1;g=j;
realloc(p, (len+1)*sizeof(int));
realloc(q, (len+1)*sizeof(int));
p[len]=line[s];
q[len]=j;
}
}
if (j+1==v)
{
i++;j=0;
}
else
{
j++;
}
}
if (control==1)
{
n++;len++;count++;
line[n]=g;
for (int x=0;x<v;x++)
{
array[x][g]=32769;
}
tk=tk+k;i=0;
}
}
}
t2=clock();
|
You have to define "complexity"
anyone? :\
Topic archived. No new replies allowed.