Menu
CodeSprout
Typo-tolerant search across every article, problem and post. to open

Prime Number Queries Explained: Sieve of Eratosthenes & Segmented Sieve | Part 2

kvi5hnu46 minutes 11 secondsWatch on YouTube
0comments

Notes

In Part 2 of the Prime Number Algorithms series, we move beyond checking a single number and learn how to efficiently solve different types of prime number queries.

In this video, you'll learn how to choose the right algorithm based on the type of query:

✅ Query Type 1: Check whether a random integer's is prime
✅ Query Type 2: Find all prime numbers from **0 to N** using the **Sieve of Eratosthenes**
✅ Query Type 3: Find prime numbers in a large range using the **Segmented Sieve**

We'll cover:

  • When each algorithm should be used
  • Time and space complexity
  • Step-by-step intuition
  • C++ implementation
  • Common interview questions

This video is perfect for:

  • DSA learners
  • Competitive programmers
  • Coding interview preparation
  • Computer Science students
  • Anyone who wants to master prime number algorithms

Practice Problems:
🔹 Find Prime Numbers in a Range (Segmented Sieve):
https://www.geeksforgeeks.org/problems/find-prime-numbers-in-a-range4718/1

🔹 Sieve of Eratosthenes:
https://www.geeksforgeeks.org/problems/sieve-of-eratosthenes5242/1

📚 Playlist: Algorithms from Scratch

If this video helped you understand prime algorithms, don't forget to Like, Subscribe, and Share. More DSA and algorithm deep dives are coming soon!

Discussion

Sign in to ask a question or share what you learned.