Re: ArrayList BinarySearch vs Contains
- From: "Brian Gideon" <briangideon@xxxxxxxxx>
- Date: 11 Nov 2006 14:32:31 -0800
Dave Sexton wrote:
Hi Bill,
It seems you are suggesting that the scale of the data can affect whether a
required sorting operation will actually reduce the overall performance of an
algorithm so that it becomes worse than a linear search. Can this be true
even when the data is sorted as it's being entered into the structure?
Yep, that's basically what he's saying. A good example of this is the
HybridDictionary. The HybridDictionary starts out as a ListDictionary
and then converts to a Hashtable when the number of items is large
enough. This works well despite the fact that the ListDictionary uses
a O(n) implementation as opposed to the Hashtable's O(1)
implementation. It would seem, based on the Big-Oh notation anyway,
that a Hashtable would always be faster, but what Big-Oh doesn't reveal
is the constant time factor which is significant in the case of a
Hashtable. Typically, a ListDictionary will outperform a Hashtable if
the number of items is less than 10.
.
- Follow-Ups:
- Re: ArrayList BinarySearch vs Contains
- From: Dave Sexton
- Re: ArrayList BinarySearch vs Contains
- From: Peter Duniho
- 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
- Re: ArrayList BinarySearch vs Contains
- From: Bill Butler
- Re: ArrayList BinarySearch vs Contains
- From: Dave Sexton
- ArrayList BinarySearch vs Contains
- Prev by Date: Re: Fixing a form on the screen
- 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):