50 Must-Do Mathematics Problems in DSA
Foundational Math & Number Theory
1. Check if a number is prime
2. Generate all prime numbers up to N (Sieve of Eratosthenes)
3. Compute GCD and LCM of two numbers
4. Check if two numbers are co-prime
5. Count the number of divisors of a number
6. Calculate the sum of divisors of a number
7. Find the number of trailing zeros in N!
8. Count the number of digits in N!
9. Check if a number is a power of two
10. Determine if a number is a perfect square
Modular Arithmetic & Large Numbers
1. Compute (a × b) mod m
2. Calculate (a^b) mod m using modular exponentiation
3. Find modular inverse of a number
4. Solve modular linear equations
5. Implement the Chinese Remainder Theorem
6. Compute factorial modulo a prime number
7. Calculate combinations (nCr) modulo m
8. Determine permutations (nPr) modulo m
9. Solve linear congruences
10. Apply Fermat's Little Theorem
Bit Manipulation
1. Check if a number is even or odd using bitwise operators
2. Find the only non-repeating element in an array where every other element repeats twice
3. Count the number of set bits in a number
4. Determine if a number is a power of two using bitwise operations
5. Find the position of the rightmost set bit
6. Toggle the k-th bit of a number
7. Find the XOR of all elements from 1 to N
8. Swap two numbers without using a temporary variable
9. Add two numbers without using the '+' operator
10. Divide two numbers without using the '/' operator
Combinatorics & Probability
1. Calculate nCr (combinations)
2. Compute nPr (permutations)
3. Find the number of subsets of a set
4. Determine the number of derangements (permutations with no fixed points)
5. Calculate the probability of at least one event occurring
6. Solve problems involving Pascal's Triangle
7. Compute the number of ways to arrange objects with repetitions
8. Determine the number of ways to partition a set
9. Calculate Catalan numbers
10. Solve problems involving the inclusion-exclusion principle
Mathematical Algorithms in DSA
1. Implement the Euclidean Algorithm for GCD
2. Use the Extended Euclidean Algorithm
3. Apply the Sieve of Eratosthenes for prime generation
4. Implement the Miller-Rabin primality test
5. Use the Pollard's Rho algorithm for integer factorization
6. Solve the Josephus problem
7. Compute the nth Fibonacci number using matrix exponentiation
8. Find the square root of a number using binary search
9. Implement the Fast Fourier Transform (FFT)
10. Use the Karatsuba algorithm for fast multiplication