Code Explainers
Code explainers tagged #binary-search
python
from difflib import SequenceMatcher from bisect import bisect_left, bisect_right
Building a fuzzy autocomplete matcher
fuzzy-matching
binary-search
ranking
Intermediate
9 steps
rust
use std::cmp::Ordering; pub struct PrefixIndex { entries: Vec<String>,
Prefix search with binary partitioning in Rust
binary-search
sorting
case-insensitive
Intermediate
7 steps
python
import bisect from typing import Sequence
Computing latency percentiles in Python
percentiles
interpolation
binary-search
Intermediate
8 steps
ruby
class WeightedSampler def initialize(weights) @entries = weights.to_a @total = @entries.sum { |_, w| w }
Weighted random sampling with binary search
weighted-sampling
binary-search
cumulative-sum
Intermediate
7 steps
ruby
# Binary search using Ruby's built-in Array#bsearch. # # There are two modes: # 1. find-minimum mode -> block returns true/false (monotonic)
Binary search patterns with Ruby's bsearch
binary-search
algorithms
ranges
Intermediate
7 steps