# Calculating Time Complexity Classic List Threaded 4 messages Open this post in threaded view
|

## Calculating Time Complexity

 Dear all, In general terms, how would one calculate the time complexity of a given algorithm? Feel free to make use of my pseudo code in your answer:                         /* input:                         2-D array A of size n by n                            output: a number max */                         Max := 0                         For i := 1 to n                           sum := 0                           For j := 1 to n                             sum := sum + A[i][j]                           End for                           If sum > max then max := sum                         End for                            Output max         Sincerely         Matthew J. Williams
Open this post in threaded view
|

## Calculating Time Complexity

 On Mon, Jan 26, 2009 at 01:04, Matthew J. Williams < [hidden email]> wrote: > Dear all, > > In general terms, how would one calculate the time complexity of a given > algorithm? I would count most significant operations. The result is Theta(n^2) (see http://en.wikipedia.org/wiki/Big_O_notation for definition of Big Theta notation). Feel free to make use of my pseudo code in your answer: > >                        /* input: >                        2-D array A of size n by n >                           output: a number max */ >                        Max := 0 >                        For i := 1 to n >                          sum := 0 >                          For j := 1 to n >                            sum := sum + A[i][j] >                          End for >                          If sum > max then max := sum >                        End for >                           Output max > > Christopher Skrz?tnicki -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20090126/6e10550a/attachment-0001.htm