Your resources are limited. You only have so much time and money to do your work, including the time and money needed to keep your knowledge, skills, and tools up-to-date. You can only work so hard, so fast, so smart, and so long. Your tools are only so powerful and fast. Your target machines are only so powerful and fast. So you have to know the limits of your resources.

Your resources are limited. You only have so much time and money to do your work, including the time and money needed to keep your knowledge, skills, and tools up-to-date. You can only work so hard, so fast, so smart, and so long. Your tools are only so powerful and fast. Your target machines are only so powerful and fast. So you have to know the limits of your resources.

-

How to respect those limits? Know yourself, know your budgets, and know your stuff. Especially, know the space and time complexity of your data structures and algorithms, and the architecture and performance characteristics your systems.

+

How to respect those limits? Know yourself, know your budgets, and know your stuff. Especially, know the space and time complexity of your data structures and algorithms, and the architecture and performance characteristics of your systems.

Space and time complexity are given as the function ''O(f(n))'' where ''n'' is the size of the input and ''f(n)'' is the asymptotic space or time required as ''n'' grows to infinity. Important complexity classes include ''f=log(n)'', ''f=n'', ''f=n**e'', and ''f=e**n''. Clearly, as ''n'' gets bigger ''O(log(n))'' is ever so much smaller than ''O(e**n)''.

Space and time complexity are given as the function ''O(f(n))'' where ''n'' is the size of the input and ''f(n)'' is the asymptotic space or time required as ''n'' grows to infinity. Important complexity classes include ''f=log(n)'', ''f=n'', ''f=n**e'', and ''f=e**n''. Clearly, as ''n'' gets bigger ''O(log(n))'' is ever so much smaller than ''O(e**n)''.

Revision as of 21:48, 25 February 2009

Your resources are limited. You only have so much time and money to do your work, including the time and money needed to keep your knowledge, skills, and tools up-to-date. You can only work so hard, so fast, so smart, and so long. Your tools are only so powerful and fast. Your target machines are only so powerful and fast. So you have to know the limits of your resources.

How to respect those limits? Know yourself, know your budgets, and know your stuff. Especially, know the space and time complexity of your data structures and algorithms, and the architecture and performance characteristics of your systems.

Space and time complexity are given as the function O(f(n)) where n is the size of the input and f(n) is the asymptotic space or time required as n grows to infinity. Important complexity classes include f=log(n), f=n, f=n**e, and f=e**n. Clearly, as n gets bigger O(log(n)) is ever so much smaller than O(e**n).

Note that capacity and speed vary by several orders of magnitude. Caching and lookahead are used heavily at every level of the system to hide this variation. When cache misses are frequent the system will be thrashing.

Algorithms vary in how effectively they use caches. For instance, linear search makes good use of lookahead, but requires O(n) comparisons. Binary search of a sorted array requires only O(log(n)) comparisons, but tends to be cache-hostile. And searching a von Embde Boas array is O(log(n)) and cache-friendly.