Correction.! While writing code... Store the value of n in a separate variable. Because, inside while loop, we are continuosly decreasing it's value and. And once you come out of the while loop and go up in the for loop. The value of "n" Is decremented. So, right thing to do is store value of 'n' in a separate variable. And use it for the 'for' loop. And use the actual 'n' everywhere inside the for loop.
@sagaralwani753 жыл бұрын
you are wrong my friend, look at it correctly, he is right, with all respect I just want to say he is correct, look at the actual mathematics, this is what happens like = 30 = 2*3*5... the first iteration divided by 2, n becomes 15 second time it will be divided by 3 and will become 5 and at last, n will be one and when i is 6, the for-loop condition will be tested as 6 is not less than 1, it won't go inside the loop and yes we are done...
@yashsalvi50433 жыл бұрын
I'm also feeling the same, that the value for sqrt(n) should be a separate variable ! Say we're checking prime factors of 50, then at first i=2; i< √50 , Now we'll go inside of while and then N will be 25, and hence we'll come out of if loop and then the condition inside of for would be like for(i=3; i< √25 ; ....) . Hence, we'll never go to i= 5 !! . That's my POV, I may be wrong though. Can anyone help me out with this ?!
@mihaisuciu66746 жыл бұрын
One of the best programming channel. Great job, i hope and wish that you are going to start posting videos again (I know it s a lot of work behind). Thank you Sir.
@AdityaSingh-ql9ke2 жыл бұрын
They cant. It was a 2 man show...and one of the guys died in an accident, He was the best coder in India in his time. SuryaHarshaNarayan aka humble_fool
@TheSachinAlam3 жыл бұрын
This is channel is still a gem!!!!
@xanrd775 жыл бұрын
This was exactly what I needed. Thank you!
@mycodeschool11 жыл бұрын
Thanks Hasibul !
@dhariri9 жыл бұрын
Very nicely explained, but by setting n explicitly inside the while loop you prevent the for loop from continuing to the next i. In the example of 6, the algorithm will return 2^1 instead of 2^1 and 3^1 (because n has been reduced to 2 which breaks the for loops rule that i must be less than n, which is now set as 2).
@dhariri9 жыл бұрын
+David Hariri that is for traditional for loops I should say where i < n
@syedsouban98706 жыл бұрын
Yes you are right David, I also observed the fault in the algorithm. The channel does not seem to reply. I guess the correct method should be i
@MohitSharma-lz1nc6 жыл бұрын
No, it is correct the last if statement will check that condition.First while will reduce n = 6 to n = 6/2 = 3 and comes out .Second time for loop will terminate as Sqrt(3)
@003kazimehrabrashid46 жыл бұрын
ya, i found nothing wrong with this code.
@Aniket7Tomar10 жыл бұрын
in the "worst case" while doesn't play a role and we get O(root n). How can we be sure that in all the other "non worst cases" even though while will be involved we wont get more than O(root n)? i do get it somewhat but not completely tnx
@sirtejabaskerville9 жыл бұрын
"while" loop might not play any role but the "for" loop will be running till n. So he reduced it to sqrt(n).
@enigmaamgine68273 жыл бұрын
One of the best channel for code learning
@sagaralwani753 жыл бұрын
6:07 I am fascinated and excited and I am in joy that you are going to answer my question, I am struggling to understand...
@moonvanestar4 жыл бұрын
BRO, hablo español, pero en verdad, llevo mucho tiempo buscando un tutorial completo de este tema, para poder mejorar la complejidad en un código, y además de que tu pseudocódigo me ayudo a mejorar el mió, lo explicaste todo muy bien!, en verdad muchas gracias, tienes un nuevo suscriptor
@ahmadahmadi839811 жыл бұрын
thanks sir, very nice lessons ... those how want really improve thier skills will be amazed by ur vedios ... thanks but sir add up some more videos on algorithems and Java language... thanks I am also B.Sc student thanks...
@cesarjom8 жыл бұрын
correction at 9:14 ? i does NOT become greater than n (n=44) at i =12, the condition to exit loop. Rather I think the presenter meant to say i becomes greater than n / 2, which is also valid reason to exit for-loop.
@verynicehuman8 жыл бұрын
i does become greater than n. i would be 12 and n would be 1 so obviously 12>1. The mistake you made is in the for loop. for(i=2;i
@shubhamAgrawal2110 жыл бұрын
very nicely explained sir,but i didn't get how in the worst case the inner while loop will execute only once...
@ajoydev88763 жыл бұрын
but, I have little bit a confusion that, first for(int i = 2; i
@doingsneakypeakylike5 жыл бұрын
This channel is gold! Thank you.
@ravikhatri245 жыл бұрын
Was gold, he died in a car accident
@adityashidlyali78144 жыл бұрын
@@ravikhatri24 is it true? Bro?
@unknownman14 жыл бұрын
@@ravikhatri24 *Idiot* , not this guy, but the co-founder of this channel died in a car accident. The voice of the guy which we hear in all videos is still alive and is working at Google.
@kushalava0072 жыл бұрын
thank you so much. Excellent explanation
@adityamore26164 жыл бұрын
first time I am interested in algorithms because of you, thanks.🙏
@akashbhadouria67274 жыл бұрын
He's no more
@adityamore26164 жыл бұрын
@@akashbhadouria6727 what no more?
@akashbhadouria67274 жыл бұрын
@@adityamore2616 He died ⚰in a road accident. This is what I heard and read comments on his videos. He's dead!
@adityamore26164 жыл бұрын
@@akashbhadouria6727 okay, RIP a good person⚰
@indiansoftwareengineer48994 жыл бұрын
@@akashbhadouria6727 Oh bro, very bad, seriously feeling bad for him. RIP, I used to watch his channel in first/second year of university, before 4-5 years, when there were no more coding channels for algorithms.............
@Nick-oe1dq4 жыл бұрын
Hello, can someone type the coding on the left I'm finding it a bit confusing
@lomeshdaheria99604 жыл бұрын
Thank you 😊😊😊 for the wonderful explanation
@aziz94889 жыл бұрын
Thanks sir but I believe that if n is prime the while loop won't execute except if i=n it will run once, is this true ?
@siddharthasharma59006 жыл бұрын
you are right.
@devendrakumar62405 жыл бұрын
but the last if statement will print the prime no.(n)
@AdrianFI3 жыл бұрын
thankyou very much i understand this very clearly
@kalyanitewari4 жыл бұрын
Thank you so very much sir, really helped a lot.
@surajpatel23084 жыл бұрын
who else is watching in 2020.
@avulalakshmidevi98074 жыл бұрын
Thanks for explain this lesson
@shahariarkabir2107 жыл бұрын
nice explanation
@BenjiBoyOfficial7 жыл бұрын
Great video !
@dontony70714 жыл бұрын
Got it bro.Thanks
@whereismycheese20895 жыл бұрын
your primeFactorization function stops when i is 6 (n is given as 44).. correct?
@ashish39444 жыл бұрын
i think it would stop before 6....at 4...since inside the value of n is being changed by the statement n/=i; so it would affect the for loop condition.
@nikhilraj62684 жыл бұрын
@@ashish3944 I will not go till 4 , it will remain at 2 and finally get 2*2*11
@decodingmathematics99573 жыл бұрын
@@nikhilraj6268 when i=2 exits, n would have become 11 , it will change sqrt(n) to 3, loop enters for i=3 , not divisible , now the loop breaks when i=4
@bipul21386 жыл бұрын
nice one sir
@janvimyadventures13103 жыл бұрын
Everyone like regional language Hindi our mother tongue But an Indian coder needs to speak English many people will be helped .
@belgacembenamira27793 жыл бұрын
Thank you
@ShivamVerma-gq2sm3 жыл бұрын
Thankyou !
@alyaaahmed44622 жыл бұрын
thanks soooooooooooooooooooo much
@hemelkhan111 жыл бұрын
very nice
@yashasgowda13613 жыл бұрын
Me watching one day before my board practical exam
@pranjalgoyal67474 жыл бұрын
What a great man So sad that he died so early. Otherwise he would have been a great teacher
@AtulSingh-xt7zb4 жыл бұрын
I think the one in this video is not Harsh, he is Animesh. Anyway, this has to be one of the best channels on programming so far.
@fredrickarichards85488 жыл бұрын
ok
@manojeet_das6 жыл бұрын
what about no. 26? square root of 26 is about 5.1 , so the value of i will never reach 13 so, it will only print 2