Skip to content
tezvyn:

Algorithms

27 bites tagged Algorithms — interview questions with model answers, and 60-second explainers.

Databases & Architecture3 min read

Database Joins: Nested, Hash, Sort-Merge

A join matches rows by trading memory for speed. Nested loops use indexes; hash joins load large sets into RAM; sort-merge streams sorted data. The optimizer hides its choice, so a missing index can force a disk-spilling hash join.

Computer Vision2 min read

How does filter separability optimize Gaussian blur and its complexity?

This tests if you know a 2D Gaussian separates into two 1D convolutions. A strong answer gives complexity as O(N^2 K^2) dropping to O(N^2 K) for an N-by-N image and K-by-K kernel. A red flag is claiming all kernels are separable or omitting dimensions.

Computer Vision2 min read

How would you implement a simple box blur on a grayscale image?

Iterate interior pixels, sum the N by N neighborhood, divide by kernel area, write to a new buffer. Spatial convolution and image filtering basics. In place updates that blur already blurred values.

Analytics & Metrics2 min read

How do you build a performant visualization for millions of time-series points?

Tests end-to-end data reduction: backend bucket downsampling like LTTB preserves visual shape, frontend uses level-of-detail rendering and viewport culling. Red flag: naive every-Nth sampling that drops peaks or sending raw millions to the browser.

Analytics & Metrics2 min read

Strategy for Visualizing Millions of Time-Series Points

Tests your strategy for balancing performance and visual fidelity with large datasets. Propose backend downsampling with an algorithm like LTTB to preserve peaks, then discuss multi-resolution data fetching on the frontend.

Analytics & Metrics2 min read

Visualize Millions of Time-Series Data Points

Tests your ability to handle large datasets by combining backend downsampling (like LTTB) with frontend multi-resolution fetching and canvas rendering. A red flag is suggesting naive sampling (every Nth point) or focusing only on frontend libraries.

Databases & Architecture2 min read

HNSW: Vector Search with a Graph Highway System

HNSW finds approximate nearest neighbors in huge datasets by building a multi-layered graph, like a highway system over local roads. It's the engine in vector databases for similarity search. The footgun: it trades perfect accuracy for massive speed gains.

Databases & Architecture2 min read

Approximate Nearest Neighbor (ANN) Search: Good Enough, Fast Enough

ANN search finds 'pretty close' neighbors in a massive dataset for a fraction of the cost of finding the exact closest one. It powers vector databases and semantic search.

Databases & Architecture2 min read

Cache Eviction: Deciding What to Forget

A cache eviction policy is the rule for discarding data when fast-access memory is full. This is crucial for databases and CDNs. The common mistake is assuming one policy, like LRU, fits all workloads, which can cripple performance on certain access patterns.

Databases & Architecture2 min read

External Merge Sort: Sorting Data Bigger Than RAM

External merge sort handles datasets too big for RAM. It sorts the data in memory-sized chunks, writes them to disk, then merges the sorted chunks back together. It's crucial for database indexing, but its speed is limited by disk I/O, not CPU.

Databases & Architecture2 min read

Sort-Merge Join: The 'Line Up and Walk' Join

A sort-merge join is like merging two sorted lines of people. It's efficient when tables are already sorted on the join key or memory is tight. The footgun: if data isn't pre-sorted, the initial sort can make it slower than other join methods.

Databases & Architecture2 min read

Hash Join: Faster Database Joins with Hash Tables

A hash join speeds up database joins by building an in-memory lookup table (a hash table) for the smaller table, then streaming the larger one past it to find matches. It's ideal for large, unsorted equijoins.

Databases & Architecture2 min read

Nested Loop Join: The Brute-Force Database Join

A nested loop join is the brute-force way to match two tables. For each row in the first table, it scans every row in the second. It's simple and effective for small tables but its performance degrades quadratically on large datasets.

Databases & Architecture2 min read

B-Tree: The Workhorse of Database Indexes

A B-tree is a self-balancing tree that keeps data sorted for fast lookups, generalizing a binary search tree by allowing nodes to have many children. It enables searches, insertions, and deletions in logarithmic time, making it ideal for large datasets.

Data Science & Analytics2 min read

Policy Gradient: Teach an Agent What to Do, Not What's Valuable

Policy gradient methods directly learn what action to take, rather than learning the value of states. They excel in continuous action spaces like robotics or when the best policy is random.

Data Science & Analytics2 min read

Markov Decision Process: A Map for Sequential Decisions

A Markov Decision Process models sequential choices with uncertain outcomes. Think of it as a game with states, actions, and rewards, but where your next move is probabilistic.

Data Science & Analytics2 min read

Q-Learning: Teaching an Agent by Trial and Error

Q-Learning teaches an agent the 'quality' of an action in a given state through trial and error, like training a pet with treats. It's used in robotics for navigation or in games where an AI learns optimal moves.

Data Science & Analytics2 min read

k-Means Clustering: Grouping Data Around Centroids

k-Means automatically groups data into a specified number of clusters (`k`) by finding the center of each group. It's used for customer segmentation, document categorization, and image compression.

Data Science & Analytics2 min read

Gradient Descent: Finding the Bottom of the Hill

Think of finding the lowest point on a foggy hill by taking steps in the steepest downward direction. It's how machine learning models learn, by iteratively minimizing a cost function. The footgun is the step size: too large overshoots, too small is too slow.

Computer Vision2 min read

Seam Carving: Resizing Images Without Distortion

Seam carving resizes images by removing or adding pixel "seams" of low importance, not by squashing or cropping the whole frame. It's used in content-aware tools to change aspect ratios without distorting key subjects like faces or buildings.

Computer Vision2 min read

Kalman Filters: Predicting Through Noise

A Kalman filter predicts an object's next position, then corrects that prediction with noisy real-world measurements. It's used in video tracking to smooth an object's path between frames or in robotics to fuse imperfect sensor data.

Computer Vision2 min read

SLAM: Mapping a Room While You're Still In It

SLAM solves a chicken-and-egg problem: you can't map a space without knowing your location, and you can't know your location without a map. It does both at once. It's used by robots and AR headsets to navigate.

Computer Vision1 min read

Eight-Point Algorithm: Finding Geometry from Image Pairs

The Eight-Point Algorithm finds the geometric relationship between two camera views of the same scene. Given at least eight matching points, it estimates the essential or fundamental matrix.

Computer Vision2 min read

FAST: High-Speed Corner Detection for Real-Time Vision

FAST finds corners by checking if a pixel is significantly brighter or darker than a ring of its neighbors. This simple, high-speed test makes it perfect for real-time video processing.

Get Algorithms bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.

Algorithms — 27 bites · Tezvyn