Unit 2: Primality Testing - Subjective Questions

CSE330 — Competitive Coding Approaches-Techniques • Practice Questions with Detailed Answers

20 questions

1

Define primality testing. Explain the difference between a prime number and a composite number, and discuss why primality testing is important in competitive programming.

2

Describe the algorithm for primality testing. Explain why it is sufficient to test divisors only up to .

3

Derive an optimized version of the primality-testing algorithm by handling even numbers separately. Analyze its time complexity.

4

Explain factorization of a number. Describe how trial division can be used to find the complete prime factorization of an integer.

5

Explain why prime factors can be found by checking divisors only up to the square root of the current value. Illustrate the method with the factorization of .

6

Compare primality testing and prime factorization. Explain the situations in which each technique is preferable.

7

Explain binary exponentiation and derive its recurrence relation. How does it reduce the computation of ?

8

Demonstrate binary exponentiation for computing . Show the important intermediate values and explain how the binary representation of the exponent is used.

9

Explain Fermat's method for primality testing. State Fermat's Little Theorem, describe the algorithm, and discuss its limitations.

10

Distinguish between a definite composite result and a probable prime result in the Fermat primality test. Why should multiple bases be used?

11

Describe the Sieve of Eratosthenes. Derive its algorithm for finding all prime numbers up to a limit and analyze its complexity.

12

Using the Sieve of Eratosthenes, list all prime numbers between and . Explain which multiples are eliminated during the process.

13

Explain the Segmented Sieve algorithm. Why is it useful for finding primes in a large interval when is too large for a normal sieve?

14

Derive the formula for locating the first multiple of a prime in a segmented interval . Explain why multiples smaller than must not always be marked.

15

Explain the problem "Mansi and her series" as an application of primality testing. Describe a general algorithm and the mathematical checks required to solve such a problem.

16

Discuss how preprocessing with a sieve can improve the solution to a series-generation problem such as "Mansi and her series" when there are multiple queries.

17

Explain the likely number-theoretic strategy for the "Collections of Pens" problem when the task involves grouping or counting pens according to prime factors. Include the role of factorization.

18

Describe how a Smallest Prime Factor (SPF) sieve can be used to factorize many numbers efficiently. Compare it with repeated factorization.

19

What is a prime palindrome? Describe an algorithm for finding the next prime palindrome greater than a given integer .

20

Prove that every even-length decimal palindrome is divisible by . Explain how this observation optimizes the next prime palindrome problem.