You are here:

C/about algorithms in 'c' language

Advertisement


Question
various criteria used for judging an algorithm

Answer
Algorithms are judged on speed and correctness. Of course an incorrect algorithm is worthless.

The speed is based on how the running time grows with the size of the data being processed. For example, with a sorting algorithm, the running time might be proportional to the square of the amount of data. So if it takes T time units to sort N items, it would take 4T time units to sort 2N items. The number of items has doubled so the running time increases by a factor of 4 (double squared). Another sorting algorithm might have a running time proportional to (N x log N) where N is the size of the data. The function (N^2) increases much faster than the function (N x log N) so the second algorithm is better. Of course this running time is theoretical. It is also useful to run the algorithm on a real machine and time it to see how it behaves with a particular CPU.

Other criteria are ease of implementation and how the algorithm behaves for certain data sets. For example how does a sorting algorithm behave on already sorted data.

The science of algorithms is large. If you want to learn more, look at my learning resources at
https://sites.google.com/site/zlatkoscodingtopics/

I hope this answer has helped you a little.

Best regards
Zlatko

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.