0
0
DSA Pythonprogramming~5 mins

Sieve of Eratosthenes Find All Primes in DSA Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main idea behind the Sieve of Eratosthenes?
It is a method to find all prime numbers up to a certain limit by repeatedly marking the multiples of each prime number starting from 2.
Click to reveal answer
intermediate
Why do we start marking multiples from the square of the current prime in the Sieve of Eratosthenes?
Because all smaller multiples of the prime have already been marked by smaller primes, so starting from the square avoids redundant work.
Click to reveal answer
beginner
In the Sieve of Eratosthenes, what data structure is commonly used to keep track of prime candidates?
A list or array of boolean values where each index represents a number and the value indicates if it is prime (True) or not (False).
Click to reveal answer
intermediate
What is the time complexity of the Sieve of Eratosthenes algorithm?
The time complexity is approximately O(n log log n), which is efficient for finding primes up to large numbers.
Click to reveal answer
beginner
How does the Sieve of Eratosthenes differ from checking primality by trial division?
The sieve finds all primes up to a limit at once by marking multiples, while trial division checks each number individually by dividing by smaller numbers.
Click to reveal answer
What number do you start with when using the Sieve of Eratosthenes to find primes?
A3
B1
C0
D2
When marking multiples of a prime p, from which number should you start marking?
Ap * p
Bp + 1
Cp * 2
D1
What does a True value in the sieve's boolean list represent?
AThe number is prime
BThe number is composite
CThe number is even
DThe number is odd
Which of these is NOT a step in the Sieve of Eratosthenes?
AMark multiples of primes as not prime
BCheck divisibility of each number by all smaller numbers
CStart from 2 and go up to the square root of the limit
DReturn all numbers still marked as prime
What is the main advantage of the Sieve of Eratosthenes over checking each number individually?
AIt uses less memory
BIt does not require any loops
CIt finds all primes up to a limit efficiently
DIt works only for small numbers
Explain how the Sieve of Eratosthenes algorithm finds all prime numbers up to a given number.
Think about crossing out multiples step by step.
You got /5 concepts.
    Describe why the Sieve of Eratosthenes is more efficient than checking each number's primality by dividing by smaller numbers.
    Focus on how the sieve reduces repeated work.
    You got /4 concepts.