Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Seeking an array index

Author: Klaus Friedel

Date: 10:49:17 01/04/05

Go up one level in this thread


On January 04, 2005 at 08:43:45, Antonio Senatore wrote:

>
>Hi friends:
>
>I need to find the index of the highest value in an array of N integer positive
>numbers. Does anyone know a faster algorithm than the following:
>
>int find_index (int *arr, int N) {
>
>   int  best_val = -INF, i,  index;
>
>   for (i = 0; i < N; i++) {
>          if (arr[i] > best_val) {
>              index = i;
>              best_val = arr[i];
>          }
>   }
>   return index;
>}
>
>Thank you very much in advance
>Antonio



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.