Re: ArrayList BinarySearch vs Contains
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Fri, 10 Nov 2006 13:34:33 -0800
"tshad" <tscheiderich@xxxxxxxxxxxxxxx> wrote in message
news:u8iJyqQBHHA.4256@xxxxxxxxxxxxxxxxxxxxxxx
Which is better to use with an ArrayList: BinarySearch or Contains?
The list is only going to have strings in it and it will be sorted.
Then BinarySearch is better. Contains will be an O(n) operation always
(since it doesn't know whether the data is sorted), while BinarySearch is an
O(lg(n)) operation. Just make sure that the data really is sorted!
-cd
.
- Follow-Ups:
- Re: ArrayList BinarySearch vs Contains
- From: tshad
- Re: ArrayList BinarySearch vs Contains
- References:
- ArrayList BinarySearch vs Contains
- From: tshad
- ArrayList BinarySearch vs Contains
- Prev by Date: TCP Send Timing Issue
- Next by Date: Re: Difference between Select and Focus?
- Previous by thread: ArrayList BinarySearch vs Contains
- Next by thread: Re: ArrayList BinarySearch vs Contains
- Index(es):