Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coding puzzle (4)
Message
From
06/06/2002 10:19:15
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00665368
Message ID:
00665423
Views:
25
Nadya:

>>>>>>>>>>
Idea:
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
>>>>>>>>>>

Good try but no cigar.

This algorithm works if you scan the array and for each value Y, you apply your idea to X-Y. However, the algorithm is of order n * Log(n) (worse than linear, better than quadratic) and not linear.

Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform