Binary search: Difference between revisions

From The K Language Wiki
Content added Content deleted
("Add all appropriate categories to each verb")
("Better category ordering, add redirects to categories, fix pseudo-adverb categories")
 
Line 12: Line 12:
</pre>
</pre>


[[Category:Adverbs]]
[[Category:Verbs]]
[[Category:Operator verbs]]
[[Category:Primitives]]
[[Category:Primitives]]

Latest revision as of 06:14, 9 July 2022

Binary search
x'y

Binary search performs a binary search for y in a list x, assuming x is sorted in ascending order. It returns the smallest index i such that y would sort after (or matches) x[i], or -1 if no such index exists.

binary search is right atomic.

  0 2 4 6 8 10'5
 2
   0 2 4 6 8 10'-10 0 4 5 6 20
 -1 0 2 2 3 5