I got a question when I started reading about searching and sorting..

my question is :

1. On what factors does program execution time depends upon ?

- its on the number of lines we have written / logic we have used / both / any other..

Printable View

- 05-19-2011suryakon what program execution time depends upon
I got a question when I started reading about searching and sorting..

my question is :

1. On what factors does program execution time depends upon ?

- its on the number of lines we have written / logic we have used / both / any other.. - 05-19-2011CommonTater
Mostly it will depend on 2 things...

1) The speed of the computer

2) The efficiency of the code.

#2 can be related to lines written, etc... but mostly it will be related to how you minimize the amount of work done to accomplish the task. For example... a linear search is very "code efficient" but on large arrays or files the further it has to look the slower it gets, finding the 1000th element takes 1000 tries... On the other hand a binary search needs more code but --provided the data is sorted-- it's going to be blazing fast finding any one of a thousand elements in only 10 tries. There are also many situations were the reverse is true... smaller code gives better results...

It's all up to our skill as programmers, part of the task is finding the most efficient way to do the job. - 05-19-2011Salem
Algorithms are usually described by their "big-O" value.

Big O notation - Wikipedia, the free encyclopedia

But this only describes what happens on an abstract machine for very large values of 'n'.

For more realistic values of 'n', or where 'n' is really small, then all the factors such as choice of processor, choice of language and programmer skill (in choosing the right algorithm, and skill at implementing the algorithm) all come into play.