Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding puzzle (4)
Message
De
06/06/2002 10:19:15
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00665368
Message ID:
00665423
Vues:
28
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform