Alan Zhan Blog

Live for nothing, or die for something

Interpolation Search Algorithm

Continuing with the number guessing game — for numbers 1 to 100, if you already know the result, using binary search might not be the most efficient approach. So what method should we use instead? …

Jump Search Algorithm

Continuing with the number guessing game — can we try a different approach for numbers 1 to 100? If we start from the beginning and jump forward by 10 each time we don’t guess correctly, we keep …

Binary Search Algorithm

Let’s play a number guessing game. Pick an integer between 1 and 100 — you have to guess the number in my head, and you must do it in the fewest guesses possible. How would you approach it? The …

Linear Search Algorithm

When checking whether an element exists, what is the most common approach? The answer is a for or while loop. Congratulations — you’ve already learned Linear Search! Concept Linear Search: This …

Divide and Conquer

Divide and Conquer As the name suggests, this approach breaks a complex problem into two or more identical or similar subproblems, solves the smaller problems, and then combines the results to produce …

Big O Notation

How to Choose an Algorithm to Solve a Problem The same problem can be solved using different algorithms, but which one is the best? There are two metrics for evaluating an algorithm: Time complexity …