Sieve of eratosthenes

Поделиться
HTML-код
  • Опубликовано: 26 дек 2024

Комментарии • 100

  • @manasvinsharma1740
    @manasvinsharma1740 3 года назад +56

    This is the only channel that has explained the concept that why to start the inner loop from i^2 & why to stop the outer loop at sqrt(n). 🤩🤩

    • @techdose4u
      @techdose4u  3 года назад +2

      🔥

    • @anshumaan1024
      @anshumaan1024 Год назад +2

      bhai mene gfg ki video dekhi..dimaag crash kr gya tha

  • @brycejohansen7114
    @brycejohansen7114 3 года назад +6

    You could write "i * i

    • @pragyan394
      @pragyan394 2 года назад +1

      The compiler would optimise that by itself

  • @abdulhannan288
    @abdulhannan288 2 года назад

    This is a very underrated channel this is a very under rated channel

  • @lavishyadav6756
    @lavishyadav6756 4 года назад +5

    I must say, you can get solution from anywhere but the thinking to solve a new problem can be easily built by looking at your approaches towards problems. Well explained.

  • @mdzaid3792
    @mdzaid3792 3 года назад +1

    The explanation is literally Supercalifragilisticexpialidocious 🔥🔥🔥

    • @techdose4u
      @techdose4u  3 года назад

      What's this word bro 😅

  • @vishaldevasi3500
    @vishaldevasi3500 3 года назад

    One thing is clear that u are a Genius...🔥👍🏽

  • @upsolver2342
    @upsolver2342 3 года назад +4

    Buddy u r awesome, u build very deep understanding and intuition of logic. Thanks for such explanations.

  • @md_nawshin_zaman
    @md_nawshin_zaman Год назад

    The exact video I was looking for. Thanks for the great video.

  • @MrMonishSoni
    @MrMonishSoni 3 года назад +2

    This is Exactly what a Good Video would look like, no extra animated stuffs only to the point. Because once the concept is clear code part is easy. Btw i would like to add here that i think sieve should me modified for odd numbers only because all the multiples of 2 i.e. 2n are anyways not prime. So Optimized Sieve = Classic Sieve + Till Root n + Odd Numbers Only.

    • @techdose4u
      @techdose4u  3 года назад +3

      Right. The numbers are already marked and so will not be processed again. I think you are suggesting to jump in values of 2 rather than 1 right ? It's a good idea to not even have to check it :)

    • @MrMonishSoni
      @MrMonishSoni 3 года назад

      @@techdose4u Ya I mean i have read it somewhere on wiki page i think because it effects on the time/space complexity. Although there are much complex sieves which are still more optmized, and i didnt get that, but as far as this video goes. this is perfect. Thanks.

    • @MrMonishSoni
      @MrMonishSoni 3 года назад +1

      @@techdose4u Also Prime Numbers are utterly the most important concept like i have came after going through some project Eulers problem and what i had observed is that it take huge understanding of just basic maths like prime numbers to just implement an efficient algorithm. Because the Numbers on project Eulers goes upto millions for primes just to make sure you dont write an inefficient code. ;) :)

    • @techdose4u
      @techdose4u  3 года назад +1

      I will cover that when I start Number theory playlist :) Concepts of primes and complex sieves.

  • @gabrieldjebbar7098
    @gabrieldjebbar7098 4 года назад +2

    Awesome explanation for the optimization ;)

  • @user-lh7rv1ts3u
    @user-lh7rv1ts3u 2 года назад

    Thank you so much, it helped on my C++ course

  • @ashutoshsinghpatel196
    @ashutoshsinghpatel196 2 года назад

    Great respect for you & your explanation of algorithms.🙏

  • @Justdoing185
    @Justdoing185 3 года назад +1

    Excellent explanation sir

  • @madhupadayeswanth1865
    @madhupadayeswanth1865 2 года назад +1

    sir i could not understand why we need to take upto sqrt(N) in first loop

  • @mounikanandimalla9321
    @mounikanandimalla9321 3 года назад +2

    That was a super explanation:)

  • @AinasDiaries
    @AinasDiaries 3 года назад

    At 3:52 why take j

  • @akansha1127
    @akansha1127 3 года назад +2

    Tysm Sir the best explanation I ever had till now I immediately subscribed to your channel because I know this will be very very useful for me ..
    Once again thank you Sir.

  • @surajbaranwal56.
    @surajbaranwal56. 2 года назад

    great job sir, well explained, easy, understandable.

  • @mohitkhandelwal5050
    @mohitkhandelwal5050 3 года назад +1

    what will be the time complexity of FIRST METHOD of sieve of eratosthenes ??????

  • @DEEPAKSAHU-ou4jy
    @DEEPAKSAHU-ou4jy 3 года назад

    ek no guruji

  • @techamet428
    @techamet428 4 года назад +3

    beautifully explained

  • @swastikpadasalkar5765
    @swastikpadasalkar5765 4 года назад +2

    Happy to see tricolors in the beginning .💜

  • @jigyasakodnani3872
    @jigyasakodnani3872 4 года назад +6

    Thanks for this video, you're explanation is amazing 😃

  • @tanmaytyagi7031
    @tanmaytyagi7031 4 года назад +1

    Very nicely explained ❤️

  • @sourav9135
    @sourav9135 3 года назад +1

    Thanks for this video but can you tell how to do this in O(n) Time complexity

  • @sivaganesh4489
    @sivaganesh4489 4 года назад +2

    Awesome please do more videos on these type of questions

  • @aizad786iqbal
    @aizad786iqbal 4 месяца назад

    that TC explanation by gfg is so complex, they haven't explained properly..
    can you please make a video explaining that ?

  • @anuragsoni2256
    @anuragsoni2256 3 года назад

    Very nice problem. Thanks!

  • @shivrajahirwar4334
    @shivrajahirwar4334 3 года назад

    very nice explanation:)

  • @vickycsk1998
    @vickycsk1998 Год назад +1

    it is not applicable for 10^12

  • @ujjwalprazapati8480
    @ujjwalprazapati8480 3 года назад +5

    The outer for loop is making sqrt(n) iterations. So, why the complexity isn't sqrt(n)LogLogn instead?
    Correct me if I am wrong.
    And Thanks for such a good explanation :)

    • @ganeshkamath89
      @ganeshkamath89 2 года назад

      I think that is because each identified number goes and marks all other multiples, thus iterating till end.

  • @mandeep2192
    @mandeep2192 4 года назад +2

    explained beautifully...

  • @Amaim123
    @Amaim123 3 года назад

    Well explained

  • @melvinkimathi8924
    @melvinkimathi8924 2 года назад

    hey Techdose, what's the name of the software that you are using to explain your code?

  • @harshpatel1385
    @harshpatel1385 4 года назад +2

    plz make playlist on dynamic,tree,graph

  • @herculean6748
    @herculean6748 2 года назад +1

    Thanks

  • @sahilgore7645
    @sahilgore7645 3 года назад

    how to prove that the factor

  • @vijaykumarlokhande1607
    @vijaykumarlokhande1607 3 года назад

    where is segmented sieve with O(n) complexity?

  • @aryaman_godara
    @aryaman_godara 2 года назад

    your color scheme was already aligned for "Independence day : azadi ka amrit mahotsav" 😂😂 kool video though

  • @Cybernetic1
    @Cybernetic1 4 года назад +1

    You are the best 💝💌

  • @ALEEMKHAWAR1
    @ALEEMKHAWAR1 2 года назад

    here I know only why to start inner loop from i^2 & outer loop upto SQRT N

  • @neghatnazir1668
    @neghatnazir1668 4 года назад +1

    thanks for this video its helpful

  • @karankanojiya7672
    @karankanojiya7672 3 года назад

    TYSM SIR!
    Respect ++ !

  • @harsimrankaur653
    @harsimrankaur653 4 года назад

    Great explanation!

  • @sarthakgupta1263
    @sarthakgupta1263 4 года назад +1

    amazing exlpanations

  • @utubecom9185
    @utubecom9185 4 года назад +1

    Sir, i have a doubt and i have put that doubt on candy distribution problem video . Sir i am waiting for the reply .......

  • @chiranjeevichiru8327
    @chiranjeevichiru8327 2 года назад

    J=j+i; how it increment

  • @divyanshusalve8173
    @divyanshusalve8173 4 года назад +1

    Nice video, although I came to see geeksforgeeks version of optimized version sieve of eratosthenes, I got a hint from this video about gfg's solution. A like for that also..

  • @happypuppy3281
    @happypuppy3281 4 года назад +1

    Please Make a video on sieve of atkins.

  • @harshpatel1385
    @harshpatel1385 4 года назад +5

    god bless you

  • @shaswatdas6553
    @shaswatdas6553 4 года назад +1

    Python code incoming..
    from math import sqrt
    def sieve(n):
    if n < 2:
    return []
    ar = [True for i in range(n+1)]
    p = []
    for i in range(2, int(sqrt(n))+1):
    if ar[i] is False:
    continue
    for j in range(i**2, n+1, i):
    ar[j] = False
    p=[i for i in range(n) if i>=2 and ar[i]]
    return p
    n = 19
    print(sieve(n))

  • @shashib16
    @shashib16 4 года назад +1

    what if, N=40 and 35 is not divisible by 2 & 3.

    • @techdose4u
      @techdose4u  4 года назад

      Then you will mark mutiples of next prime number which is 5.

  • @sambhumahato8320
    @sambhumahato8320 4 года назад +1

    Awesome❤️

  • @harshpatel1385
    @harshpatel1385 4 года назад +2

    can you make video of solution of leetcode

    • @techdose4u
      @techdose4u  4 года назад

      I will do it whenever I get time.

  • @MohamedMahmoud-dn5pm
    @MohamedMahmoud-dn5pm 4 года назад +1

    good way.....thanks

  • @khageswarmalakar2011
    @khageswarmalakar2011 4 года назад +1

    Thank you

  • @gyanprakashraj4062
    @gyanprakashraj4062 2 месяца назад

    SEIVE MAANE CHHANII HOGAA😂😂😂

  • @mdfahadkhan518
    @mdfahadkhan518 2 года назад

    No ,, your logic is wrong. We can continue the loop till Square Root of number

  • @supernova7870
    @supernova7870 4 года назад +4

    First viewer

  • @gyanprakashraj4062
    @gyanprakashraj4062 2 месяца назад

    BASIC NUMBER THEORY....PADHO....

  • @ruthvikmankari1340
    @ruthvikmankari1340 4 года назад +2

    Thank You