MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Finding Position in an ordered list


Dear All,

0. Now I disclose that I am looking for a word in a dictionary.
1. Thank for the BinarySearch idea. It is much faster than Position.
2. The idea of interpolation in the case of numbers is fantastic.
3. However, I tried BinarySearch[{a,b,c},b] without being evaluated.

Thus, I need further help.

Thank for all of you.

Janos

On 6/7/05, yehuda ben-shimol <bsyehuda at gmail.com> wrote:
> The immediate answer is to perform a binary search. This will result
> with a complexity of O(Log[2,n]) (n being the length of the list) and
> not O(n).
> There is an implementation of a binary search algorithm in the
> Combinatorica package
> << DiscreteMath`Combinatorica`
> ? BinarySearch
> 
> good luck
> yehuda
> On 6/6/05, janostothmeister at gmail.com <janostothmeister at gmail.com> wrote:
> > I wonder if it is possible to use the knowledge
> > that a list in which I am looking for the position
> > of an element is ordered. I want a quicker solution then e.g.
> > lis={ac,dmk,rfg,sty,zxxer}
> > Position[lis,sty]
> >
> > I am certainly interested in longer lists...
> >
> > Thank you,
> >
> > Janos
> >
> >
> >
>


  • Prev by Date: Re: Mathematica TeX save in standard LaTeX style
  • Next by Date: Re: Centering of graphics
  • Previous by thread: Re: Finding Position in an ordered list
  • Next by thread: Re: Re: Finding Position in an ordered list