while(a.[mid].equals('city1') && a[mid+1].equals('city2') ){ mid = low+high/2; if(a[mid]=='city1' && a[mid+1]=='city1') low=mid; else if (a[mid]=='city2' && a[mid+1]=='city2') high=mid; }
On Thu, Nov 12, 2009 at 3:39 PM, Dennis <tyra...@gmail.com> wrote: > Hello, here's the deal... > > I have an ordered array containing 'Person' objects. The array is > ordered by the city the person lives in. > > My array contains people from 2 different cities. > > Now i need to find the highest index of the first city in the array > using a binairy search algoritm, i have had several tries but i can't > seem to figure it out, so i was hoping some of you could help me > out... > > The programming language is Java, but i guess that doesn't realy > matter much. > > Thanks in advance, > Dennis > > -- > > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=. > > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=.