Saturday, February 18, 2006

Algorithm Complexity - don't forget it, please



It is interesting to see how fast the software engineers are able to forget everything they have learnt about algorithm complexity. Personally, I spent a lot of time trying to show the importance of complexity to my students. Complexity is not only important as a way to evaluate and select the best algorithm for a specific problem, it is a way of thinking...

Complexity analysis is engineering methods applied to programming

With the new languages, new platforms, new and powerful computers... it is not as important, as it was, to think before coding. We code now the very first thing we think. We execute... and, if there's no error, that's all.

We have powerful libraries and frameworks. We don't need to implement from scratch a stack, queue, list, hash table, etc. We just use the implementation that comes with our environment, and sometimes we think that's enough. And of course, it isn't.

Do you know which is the complexity (temporal and spatial) of the different methods or functions of the library you are using ? Even in the case you know them, have you considered them in your proposed solution ? Sometimes you have several alternatives, did you consider them ?

Did you think about complexity the last time you implemented something ?

Computational resources ... With the new technologies perhaps we have to change the traditional approximation to complexity. Traditionally we speak about temporal and spatial cost as the main computational resources (memory and time). But... with a client/server approach, with distributed or grid systems... do we consider the network traffic ? It's just an example.

UML and all the new methodologies for analysis and design are forcing us to think before facing the coding stage. But, once we are coding, and I'm not talking only about Information Systems but any kind of application, do we apply what we have learnt about complexity ? Are we forgetting what makes us engineers when we code ?

Answer these questions:

  • Is it worthwhile to sort an array of elements before undertaking some searches on it ?

  • Is it better to use either a binary search tree or a hash table ?

  • Is Quicksort your best choice whenever you want to sort out an array ?

  • Is it better to get a/some table/s of a data base from the server to the client and afterwards carry out the queries ?

If you have answered these questions with anything different to a 'depends on', may be you have to review your information about complexity.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.