This preview shows page 1. Sign up to view the full content.
Unformatted text preview: R-3.7
The worst case running time of ﬁnd2D is O(n2 ). This is seen by examining the
worst case where the element x is the very last item in the n × n array to be examined. In this case, ﬁnd2d calls the algorithm arrayFind n times. arrayFind will
then have to search all n elements for each call until the ﬁnal call when x is found.
Therefore, n comparisons are done for each arrayFind call. Since arrayFind is
called n times, we have n ∗ n operations, or an O(n2 ) running time. This is not
a linear time algorithm; it is quadratic. If this were a linear time algorithm, the
running time would be proportional to its input size. ...
View Full Document
- Spring '12