When comparing two algorithms, there are many metrics one could use, but most of these measurements are platform and implementation dependent (meaning that the results of the measurements depend on what type of computer the algorithm is running on, and how well the algorithm was coded. Note that when coding complex algorithm, programmers have a great deal of liberty in what data structures are used, how certain processes are implemented, etc). Computer scientists need a measure for comparing algorithms in abstract terms. This abstract measurement is called efficiency. Efficiency measures the complexity of an algorithm, measuring how many abstract, conceptual operations it needs to perform.
Efficiency is often measured in terms of Big-O notation, written as O() . Algorithms are then described in terms of the number of abstract operations they perform. For example, the bubble sort algorithm runs in O(n 2) time while quicksort runs in O(nlogn) time. By comparing the Big-O's of two algorithms, one can quickly visualize which algorithm will work faster under certain situations.
Take a Study Break!