Alan Zhan Blog

Live for nothing, or die for something

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 …

Emotional Blackmail

What Is Emotional Blackmail? Before discussing emotional blackmail, we need to understand what it actually is. Emotional blackmailers may consciously or unconsciously use demands, threats, pressure, …

Atomic Habits

Compound Interest The word “compound interest” runs throughout this entire book. We can say it is the eighth wonder of the world, and that would be no exaggeration. If you improve by just …