Sie sind auf Seite 1von 1

ICT 2122 Design and Analysis of Algorithms

Growth-Rate Functions and Computing Time Time requirement is constant, and it is independent of the problems size. O(1) Time requirement for a logarithmic algorithm increases slowly as the problem O(log2n) size increases. Time requirement for a linear algorithm increases directly with the size of the O(n) problem. Time requirement for an n*log2n algorithm increases more rapidly than a linear O(n*log2n) algorithm. Time requirement for a quadratic algorithm increases rapidly with the size of the O(n2) problem. 3 Time requirement for a cubic algorithm increases more rapidly with the size of O(n ) the problem than the time requirement for a quadratic algorithm. n As the size of the problem increases, the time requirement for an exponential O(2 ) algorithm increases too rapidly to be practical. An algorithm can require different times to solve different problems of the same size. o Eg. Searching an item in a list of n elements using sequential search. Cost: 1,2,...,n Worst-Case Analysis The maximum amount of time that an algorithm requires to solve a problem of size n. o This gives an upper bound for the time complexity of an algorithm. o Normally, we try to find worst-case behavior of an algorithm. Best-Case Analysis The minimum amount of time that an algorithm requires to solve a problem of size n. o The best case behavior of an algorithm is NOT so useful. Average-Case Analysis The average amount of time that an algorithm requires to solve a problem of size n. o Sometimes, it is difficult to find the average-case behavior of an algorithm. o We have to look at all possible data organizations of a given size n, and their distribution probabilities of these organizations. o Worst-case analysis is more common than average-case analysis.

Functions of number of inputs and its related Big Ohs. = 7 O(1) = log + 3 O(log n) = 3 + 5 O(n) 2 = 4 + 15 + 90 O(n2) 3 = 10 30 O(n3) (3 +3) = 2 O(2n) Big-Oh n f(n) is O(g(n)) if f(n) is asymptotically less than or equal to g(n) big-Omega n f(n) is W(g(n)) if f(n) is asymptotically greater than or equal to g(n) big-Theta n f(n) is Q(g(n)) if f(n) is asymptotically equal to g(n)
Department of Physical Science VCUJ

Das könnte Ihnen auch gefallen