in reply to Re^4: Brute force vs algorithm (PWC # 100)
in thread Brute force vs algorithm (PWC # 100)
And I think there is no algorithm which can guaranty otherwise.
consider this input
2 2 2 2 2 2 2 2 2 2 . . . . . 2s in between 2 2 . . 2 1 last row
no matter which top-down search you apply, you can move the 1 in a way that it's only found at last try.
Which means all cells needed to be visited.°
°) NB: complexity big O() calculations are about worst case (if not stated otherwise )
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|