Re: ArrayList BinarySearch vs Contains
- From: "Bill Butler" <qwerty@xxxxxxxx>
- Date: Sat, 11 Nov 2006 20:08:26 GMT
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:12la6mse5o0gsf6@xxxxxxxxxxxxxxxxxxxxx
<snip>
If you have a sorted array, it's true that the worst case is
O(log(n)).
Everyone is making wonderful points on this topic, but I wanted to
underline a few key points.
As Peter said, a BinarySearch on a sorted ArrayList (or a balanced
Binary tree) will have a Worst case performance of O(log(n)).
Another important point of Big O notation is that it describes
Asymptotic behavior. Thus for sufficiently large n an O(log(n))
algorithm will outperform an O(n) algorithm. The problem is determining
what constitutes "sufficiently large n". For small values of n,
O(log(n)) algorithms often perform WORSE than linear algorithms do to
the additional setup complexity. Of course, for small collections, ANY
search will be fast, so it doesn't really matter.
Bill
.
- Follow-Ups:
- Re: ArrayList BinarySearch vs Contains
- From: Dave Sexton
- Re: ArrayList BinarySearch vs Contains
- References:
- ArrayList BinarySearch vs Contains
- From: tshad
- Re: ArrayList BinarySearch vs Contains
- From: Carl Daniel [VC++ MVP]
- Re: ArrayList BinarySearch vs Contains
- From: tshad
- Re: ArrayList BinarySearch vs Contains
- From: Dave Sexton
- Re: ArrayList BinarySearch vs Contains
- From: Peter Duniho
- ArrayList BinarySearch vs Contains
- Prev by Date: Re: C# using classes from C++ DLL
- Next by Date: Re: Fixing a form on the screen
- Previous by thread: Re: ArrayList BinarySearch vs Contains
- Next by thread: Re: ArrayList BinarySearch vs Contains
- Index(es):
Relevant Pages
|
Loading