Bird
0
0
DSA Cprogramming~5 mins

Sieve of Eratosthenes Find All Primes in DSA C - 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 prime number in the Sieve of Eratosthenes?
Because all smaller multiples of that 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 does a 'true' value in the boolean array represent?
It means the number at that index is currently considered prime (not marked as a multiple of any smaller prime).
Click to reveal answer
intermediate
What is the time complexity of the Sieve of Eratosthenes algorithm?
The time complexity is O(n log log n), which is very efficient for finding primes up to n.
Click to reveal answer
beginner
How does the Sieve of Eratosthenes help in real-life situations?
It helps quickly find prime numbers which are useful in cryptography, hashing, and random number generation.
Click to reveal answer
What is the first prime number used to start the sieve?
A3
B1
C0
D2
When marking multiples of a prime p, from which number do we start?
Ap * p
B2
Cp
D1
What does a false value in the sieve array mean after processing?
AThe number is prime
BThe number is zero
CThe number is composite
DThe number is negative
Which data structure is commonly used to implement the sieve?
ALinked list
BBoolean array
CStack
DQueue
What is the main benefit of the Sieve of Eratosthenes compared to checking each number individually?
AIt is faster for large ranges
BIt works only for small numbers
CIt finds only even primes
DIt uses less memory
Explain how the Sieve of Eratosthenes finds all prime numbers up to a given number n.
Think about crossing out multiples step by step.
You got /4 concepts.
    Describe why starting to mark multiples from p squared is an optimization in the sieve.
    Consider what happens to multiples less than p squared.
    You got /3 concepts.