Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding puzzle (4)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00665368
Message ID:
00665428
Vues:
21
That's not really elogant...

By k, I assume you are talking about k=alen(arr) ?

You do find the maxium value in log time.

But I think it might be better, just to:

max_element = 0
max_index = 0
for k = alen(arr) to 1 step -1
if X >= arr(k)
max_element = arr(k)

endif
endfor

>test = arr[int(k/2)]
>if X < test && We don't need to check the rest of the array
> test = arr[int(k/4))
> if X < test && we don't need to check 3/4 of the array
> ...
> endif
>endif
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform