Lecture 01: Practice Problems

1. Logarithm Simplification

Approximate the value of lg(1,000,000) to the nearest integer.

Show Answer

Answer: 20.

2^10 = 1024 approx 10^3.

2^20 = (2^10)^2 approx (10^3)^2 = 10^6 = 1,000,000.

2. Basic Probability

If you have an array of 5 unique numbers, what is the probability that they are already sorted in ascending order?

Show Answer

Answer: 1/120.

There are 5! = 120 permutations. Only 1 is sorted.

3. Algorithm Inputs

Identify the input and output for the "Primality Testing" problem.

Show Answer

Input: A positive integer n.

Output: Boolean (True if n is prime, False otherwise).