pls answere this,
which of the following takes less cpu time?
1.
for(i=0;i<1000;i++)
for(j=0;j<100;j++)
x=y;
2.
for(j=0;j<100;j++)
for(i=0;i<1000;i++)
x=y;
pls answere this,
which of the following takes less cpu time?
1.
for(i=0;i<1000;i++)
for(j=0;j<100;j++)
x=y;
2.
for(j=0;j<100;j++)
for(i=0;i<1000;i++)
x=y;
Why don't you time it and see? It looks like a pretty useless algorithm to me...
If you understand what you're doing, you're not learning anything.
Looks like it would take the same amount of time to me.
>>which of the following takes less cpu time?
Work it out for yourself, or rather should I say, let your computer work it out for you.
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Or if you have it:
http://www.rt.com/man/time.1.html
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]