Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coding puzzle (4)
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00665368
Message ID:
00665428
Views:
20
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
Previous
Reply
Map
View

Click here to load this message in the networking platform