Skip to main content
deleted 1 character in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve thisthe problem. Like flinty's answer it uses a binary search but it appears to be faster.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

It is manyFor a list of decent size, bsearchMax can be orders of magnitude faster than FirstPosition for a list of decent size.

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve this problem. Like flinty's answer it uses a binary search but it appears to be faster.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

It is many orders of magnitude faster than FirstPosition for a list of decent size.

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve the problem. Like flinty's answer it uses a binary search but it appears to be faster.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

For a list of decent size, bsearchMax can be orders of magnitude faster than FirstPosition.

deleted 1 character in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve this problem. Like flinty's answer it uses a binary search but it appears to be much faster on the simple test that I used.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

It is many orders of magnitude faster than FirstPosition for a list of decent size.

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve this problem. Like flinty's answer it uses a binary search but it appears to be much faster on the simple test that I used.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

It is many orders of magnitude faster than FirstPosition for a list of decent size.

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve this problem. Like flinty's answer it uses a binary search but it appears to be faster.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

It is many orders of magnitude faster than FirstPosition for a list of decent size.

Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

This question is closely related to the question Best way to insert element into an ordered list at the correct position?, where it was noted that Leonid Shifrin's bsearchMax from this answer is a fast way to solve this problem. Like flinty's answer it uses a binary search but it appears to be much faster on the simple test that I used.

bsearchMax[{1, 4, 10, 12, 20}, 11]

4

It is many orders of magnitude faster than FirstPosition for a list of decent size.