R-3.7 - R-3.7 The worst case running time of find2D is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: R-3.7 The worst case running time of find2D 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, find2d calls the algorithm arrayFind n times. arrayFind will then have to search all n elements for each call until the final 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

Ask a homework question - tutors are online