No video

improving naive gcd

  Рет қаралды 315,827

NOC16 CS11

NOC16 CS11

Күн бұрын

Пікірлер: 50
@ANAND-zw1on
@ANAND-zw1on 2 жыл бұрын
We can further simplify this by starting the loop from min(m, n) /2 to 1 and seperate sentence for testing the min(m, n) . Eg: if we take 100 and want to know the factors, first 100 is a factor, then there is no factor from 99 to 51. So we can skip that part completely. This is true for every other numbers.
@tavilefty
@tavilefty 2 жыл бұрын
exactly man. this comment needs to be pinned.
@girish8579
@girish8579 Жыл бұрын
What about odd numbers?
@mrtalksick6178
@mrtalksick6178 Ай бұрын
@@girish8579 instead of dividing by 2, take the quotient of the division i.e. min(m, n)//2.
@abhishek-wt5xm
@abhishek-wt5xm 4 жыл бұрын
i dont know why people are getting difficulties in understanding but i would must say i there cant be an easier explanation. really a great resource for understanding the algorithm syntax and know the best solution you also explained the way to decrease the time and ans space complexity of the algorithm thankyou
@coldcoke9254
@coldcoke9254 Жыл бұрын
probably because it s the first lecture and we are already using concepts of functions and loops and lists...I'd recommend watching a one shot lecture on python by codewithharry and then coming to this that's what I did and now all this seems really simple...don't even need to watch all of it only till chapter 8.
@ruturajjadhav8905
@ruturajjadhav8905 4 жыл бұрын
def gcd(num1,num2): return max(list(set([i for i in range(1,num1+1) if num1 % i == 0]).intersection(set([i for i in range(1,num1+1) if num1 % i == 0])))) ## intersection : combines the common factors of given two sets ##just two lines
@SlickShitt
@SlickShitt 3 жыл бұрын
after intersection you used the first parameter instead of num2
@adityamehra7238
@adityamehra7238 2 жыл бұрын
My brain literally exploded after realising there was 1 another way to write code for this gcd...... Meanwhile professor : you said 1? Wait hold my mike...... 💥💥... A beautiful lecture
@BiswajitDas-lk7pp
@BiswajitDas-lk7pp 2 жыл бұрын
Amazing 😀😀😀
@mandarchincholkar7250
@mandarchincholkar7250 5 жыл бұрын
Marvelous logic... Amazing... 👏👏👏👏🎉🎉🎊🎊🎊 only experienced programmers will get it..🔥🔥🔥
@panthrohit
@panthrohit 5 жыл бұрын
Not an experienced programmer, still I get it... :)
@mandarchincholkar7250
@mandarchincholkar7250 5 жыл бұрын
@@panthrohit then you nailed it hardly.. 😎😎😎😎
@panthrohit
@panthrohit 5 жыл бұрын
@@mandarchincholkar7250 This reminds me of the saying 'working hard or working hardly'. Whats my takeaway here....🤔😛😬
@mandarchincholkar7250
@mandarchincholkar7250 5 жыл бұрын
@@panthrohit bhai baat ko mat ghumaya kar.. 😂😂😂😂😂
@panthrohit
@panthrohit 5 жыл бұрын
@@mandarchincholkar7250 😉
@ashishkumarsharma1323
@ashishkumarsharma1323 Жыл бұрын
def gcd(m, n): i= min(m, n) while(i>0): if (m%i == 0 and n%i== 0): return(i) else: i=i- 1 x=gcd(21, 9) print(x)
@coldcoke9254
@coldcoke9254 Жыл бұрын
probably because it s the first lecture and we are already using concepts of functions and loops and lists...I'd recommend watching a one shot lecture on python by codewithharry and then coming to this that's what I did and now all this seems really simple...don't even need to watch all of it only till chapter 8.
@anshulojha5699
@anshulojha5699 4 жыл бұрын
The algo that u explain if I will learn that methods to minimize the all codes with time and memory then I will be the rank 1 in Google contests 🙏🙏
@sameers8510
@sameers8510 3 жыл бұрын
You are simply superb sir Awesome explanation
@bhargavdobariya5859
@bhargavdobariya5859 3 жыл бұрын
great explanation....thanks a lot sir
@izharkhankhattak
@izharkhankhattak 2 жыл бұрын
nice
@vatsal_gamit
@vatsal_gamit 3 жыл бұрын
def gcd3(m,n): return max([i for i in range(1,min(m,n)+1) if ((m%i)==0 and (n%i)==0)]) print(gcd3(3575,978))
@tavilefty
@tavilefty 2 жыл бұрын
wonderful lecture.
@arpita0608
@arpita0608 6 жыл бұрын
The shorter python program was confusing min(m, n) this part
@vatsalgupta00
@vatsalgupta00 6 жыл бұрын
Divisor of a number cannot be larger than the number. Since we are trying to find common divisors, only divisors of smaller number are suffcient.
@DineshJunjariyaBEE
@DineshJunjariyaBEE 4 жыл бұрын
min(m,n) gives least of the two numbers
@anshulojha5699
@anshulojha5699 4 жыл бұрын
Like min(6,8) so dono me vo common no hoga vo 6 se thoe hamesha less hi hoga like 2 here . That's why they used this concept ✅
@mritunjay3723
@mritunjay3723 3 жыл бұрын
A one line code -- print(next(a for a in range(63,0,-1) if 8888%a==0 and 63%a==0))
@sravanchilumula5213
@sravanchilumula5213 5 жыл бұрын
classes are in not the correct order please correct it!
@pratapkhandekar8322
@pratapkhandekar8322 5 жыл бұрын
You are explaining code directly It is hard to understand
@sanjayguptacg486
@sanjayguptacg486 5 жыл бұрын
low sound.
@sagarsagar-xr7bo
@sagarsagar-xr7bo 4 жыл бұрын
Low sound boring ,speak loudly sir
@prashnatdivase8523
@prashnatdivase8523 4 жыл бұрын
def gcd(m,n): fm=[] # list down factor of m in fm fn=[] # list down factor of m in fn for i in range(1,m+1): if (m%i ==0): fm.append(i) print("fm is",fm) for j in range(1,n+1): if (n%j ==0): fn.append(j) print("fn is",fn) cf=[] # for returning largest value for k in fm: if k in fm: cf.append(k) print("The largest GCD is: %d "%cf[-1]) gcd(10,8) above programs give correct output but i would like to understand why below program is not giving same output: def gcd(m,n): i=min(m,n) while i>=0: if m%i==0 and n%i==0: return i else: i=i-1 v=gcd(10,8) print(v) Sorry if i am missing anything and would be great if someone explain last optimize example in details
@coldcoke9254
@coldcoke9254 Жыл бұрын
the code works just fine tho, just chane
@venkatashasidharreddychali7485
@venkatashasidharreddychali7485 Жыл бұрын
give the brackets correctly, it worked for me, I alos got the wrong output when i used this (m%i) ==0 & (n%i) ==0 after tweaking it to this ((m%i) ==0) & ((n%i) ==0), i got the correct output
@prashnatdivase8523
@prashnatdivase8523 Жыл бұрын
@@venkatashasidharreddychali7485 thank you
@bhupiagra1
@bhupiagra1 6 жыл бұрын
you said actually any common factor must be less than min(m, n) but how this statement is justifying gcd of (2, 4) ?
@tabassumhebbalkar
@tabassumhebbalkar 6 жыл бұрын
including the minimum of both.
@panthrohit
@panthrohit 5 жыл бұрын
Must be less than or equal to min(m,n)
@DineshJunjariyaBEE
@DineshJunjariyaBEE 4 жыл бұрын
he meant min or less than min
@exploringlife2904
@exploringlife2904 4 жыл бұрын
not running in python mrcf
@gauravjoshi7589
@gauravjoshi7589 3 жыл бұрын
i am not getting any error and also not getting any output
@sumitbhattacharyya2058
@sumitbhattacharyya2058 6 жыл бұрын
sound quality is not satisfactory
@pk15692
@pk15692 5 жыл бұрын
You can use a volume booster for chrome to enhance the sound volume
@sagarsagar-xr7bo
@sagarsagar-xr7bo 4 жыл бұрын
@@pk15692 try chesaa ,no use
@sujathalaveti
@sujathalaveti 6 ай бұрын
Use ear phones
euclid's algorithm for gcd
23:55
NOC16 CS11
Рет қаралды 285 М.
assignment statement, basic types - int, float, bool
21:58
NOC16 CS11
Рет қаралды 255 М.
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 22 МЛН
The Joker saves Harley Quinn from drowning!#joker  #shorts
00:34
Untitled Joker
Рет қаралды 70 МЛН
Kids' Guide to Fire Safety: Essential Lessons #shorts
00:34
Fabiosa Animated
Рет қаралды 15 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 7 МЛН
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 827 М.
SQL Tutorial for Beginners [Full Course]
3:10:19
Programming with Mosh
Рет қаралды 11 МЛН
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 39 МЛН
breaking out of a loop
12:26
NOC16 CS11
Рет қаралды 107 М.
Hash Tables and Hash Functions
13:56
Computer Science
Рет қаралды 1,5 МЛН
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 642 М.
Recursion in Programming - Full Course
1:51:36
freeCodeCamp.org
Рет қаралды 941 М.
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
Python Tutorials - Program To Find out the GCD of Two Positive Numbers
13:11
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 22 МЛН