Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
@parassirohi8305
Жыл бұрын
sir, this exercise solution is not opening. How can i check my answer?????
@alexlu2
7 ай бұрын
Hi, if you prefer to make the code a bit shorter, there is actually no need to use a tmp variable. Instead of: tmp = elements[j] elements[j] = elements[j+1] elements[j+1] = tmp Use: elements[j], elements[j+1] = elements[j+1], elements[j] This is a neat trick in python that allows the value of two variables to be swapped.
@naveenchahar8074
3 жыл бұрын
for many months I delayed learning DS but since I have found your channel, now DS seems really easy. Specially the exercise part I like most. Thankyou Sir from the depth of my heart. Saviour of students like me.
@codebasics
3 жыл бұрын
I am happy this was helpful to you.
@mishratech1mviews3hourago39
2 жыл бұрын
Me to bro
@tharindusathsara3414
Жыл бұрын
Really very happy about finding such an obvious and understood funny video series about data structures and algorithms. Everything is 100% clear with deeply explained theories and well-understood practicals. Also, the exercise series with the videos are highly appreciated. Dear sir thank you so much for the fantastic video series. ❤💖
@danieltaylor7040
3 жыл бұрын
The swapped flag is a good catch on making sure best case is O(n). Most other implementations I've seen do not have this flag, and thus don't take advantage of a pre-sorted array.
@rajmalla5310
11 ай бұрын
U are true guru, people only explain how to do it but they do not explain why. And only a true teacher would explain both how and why. I didn't understand why that -i part, but u made it clear. thankyou so much SIrr
@hrushikeshkulkarni7353
2 жыл бұрын
I loved the way you optimised bubble sort from O(n^2) to O(n) using swapped flag
@iwuomasolomonuched518
4 ай бұрын
Your approach to problem solving is genius.
@奶油雞雞
3 жыл бұрын
sir, thanks a lot!! It's solved my n-1-i problem. some books said it was actually i+1 and written as n-1-i in code, and i was so confused. now i know its cause un-efficient for loop to continue, so we need n-1-i to shorten the loop when the last digit was found , thank you !!!
@LokeshKumar-dd2qw
4 жыл бұрын
Thank you, Mr. Dhawal, I can't believe this content is free.
@codebasics
4 жыл бұрын
👍😊
@jagadeeshchowdary481
3 жыл бұрын
easy solution for above exercise question def bubblesort(elements, key="name"): size = len(elements) for i in range(size-1): for j in range(size-1): if (elements[j])[key] > (elements[j+1])[key]: tmp = elements[j] elements[j] = elements[j+1] elements[j+1] = tmp return elements
@joacimodhiambo1794
2 жыл бұрын
def bubble_sort(val, key='name'): size = len(val) for i in range(size - 1): for j in range(size - 1 - i): if val[j][key] > val[j + 1][key]: tmp = val[j][key] val[j][key] = val[j + 1][key] val[j + 1][key] = tmp return val
@Manikanta-lc5zu
12 күн бұрын
@@joacimodhiambo1794😂
@sukurcf
3 жыл бұрын
holy hell. heard a lot about bubble sort. but never knew why it's called so.
@miteshbarnwal8239
Жыл бұрын
Hi Sir, I was having difficulty in understanding bubble sort, from your video it is crystal clear now. Thanks
@ij953
2 жыл бұрын
Explained so well, love the way you implement DSA efficiently
@trendinggameplay99
2 жыл бұрын
very good explanation, i have been searching for a video just like this, thank You sir
@codebasics
2 жыл бұрын
Glad it helped
@gaganbhattacharya9890
10 ай бұрын
Amazing step by step explanation! Thank You Sir!
@techsavvyinfo
2 жыл бұрын
i have seen many bubble sort but yours is best
@tripathi5174
4 жыл бұрын
thankyou once again sir for continuing with the series. Take care sir!
@codebasics
4 жыл бұрын
👍😊
@bigbang3235
4 жыл бұрын
Sir please make videos on dynamic programming
@codebasics
4 жыл бұрын
Sure
@treksis
3 жыл бұрын
excellent sort algo tutorials from bubble to selection. thank you
@murciadaniel
4 жыл бұрын
Loving this !!! Thank you!
@sayanjitb
3 жыл бұрын
Dear sir, I have done the last exercise on my own as follows and worked successfully: ----------------------------------------------------------------------------------------------- def bubble_sort(arr,key='name'): u=[ ] #empty list size=len(arr) for k in range(len(arr)): u.append(arr[k].get(key)) for i in range(size-1): swapped=False for j in range(size-1-i): if u[j] > u[j+1]: temp=u[j] u[j]=u[j+1] u[j+1]=temp swapped=True if not swapped: break return u If you kindly give any suggestion, it would be very much helpful to me.
@RahulSharma-lw2ss
Жыл бұрын
nicely explained
@anirbanc88
2 жыл бұрын
i love your exercises!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@Codingiisgreat
3 жыл бұрын
#Bubble Sort def bubble_sort(elements,key): size = len(elements) for i in range(size-1): swapped = False for j in range(size-1-i): if elements[j][key] > elements[j+1][key]: elements[j], elements[j+1] = elements[j+1], elements[j] swapped = True if not swapped: break if __name__ == '__main__': elements = [ {'name': 'kathy', 'transaction_amount': 200, 'device': 'vivo'}, {'name': 'dhaval', 'transaction_amount': 400, 'device': 'google pixel'}, {'name': 'aamir', 'transaction_amount': 800, 'device': 'iphone-8'}, {'name': 'mona', 'transaction_amount': 1000, 'device': 'iphone-10'}, ] bubble_sort(elements,'transaction_amount') print(elements)
@johnk9621
3 жыл бұрын
You were very grave at the end of the video! I miss the coronavirus prank at each video-endding! Hahaha
@skoushik3799
3 жыл бұрын
Crystal clear tutorial!
@ranjithkumarneeruganti4710
3 жыл бұрын
Great Playlist - Thank you😊😊
@codebasics
3 жыл бұрын
Glad you enjoyed it
@Schadenfreude596
7 күн бұрын
My solution for exercise def bubble_sort(elements, key): size = len(elements) - 1 for _ in range(size): swapped = False for i in range(size): if elements[i][key] > elements[i+1][key]: elements[i][key], elements[i+1][key] = elements[i+1][key], elements[i][key] swapped = True if not swapped: break return elements elements = [ { 'name': 'mona', 'transaction_amount': 1000, 'device': 'iphone-10'}, { 'name': 'dhaval', 'transaction_amount': 400, 'device': 'google pixel'}, { 'name': 'kathy', 'transaction_amount': 200, 'device': 'vivo'}, { 'name': 'aamir', 'transaction_amount': 800, 'device': 'iphone-8'}, ] print(bubble_sort(elements, key='name'))
@nan4061
3 жыл бұрын
Thank you for this excellent tutorial!
@codebasics
3 жыл бұрын
You're very welcome!
@joacimodhiambo1794
2 жыл бұрын
The solution to the exercise is available, please check.
@a.human.
2 жыл бұрын
Your explanation is fantastic, sir. Respect!
@pythonenthusiast9292
4 жыл бұрын
plans on competetive programming for interviews? This is channel focusses on data science but your videos are simply awesome .. please try to make that also if possible
@codebasics
4 жыл бұрын
yes I will add videos on that
@KhelGyanOfficial
3 жыл бұрын
Solution page is not opening.So I am pasting my code here :- def bubble_sort(elements,key): size=len(elements) IsSwapped=0 for i in range(size-1): for j in range(size-1-i): if elements[j][key] > elements[j+1][key]: tmp=elements[j][key] elements[j][key]=elements[j+1][key] elements[j+1][key]=tmp IsSwapped=1 if IsSwapped==0: break def main(): elements = [ { 'name': 'mona', 'transaction_amount': 1000, 'device': 'iphone-10'}, { 'name': 'dhaval', 'transaction_amount': 400, 'device': 'google pixel'}, { 'name': 'kathy', 'transaction_amount': 200, 'device': 'vivo'}, { 'name': 'aamir', 'transaction_amount': 800, 'device': 'iphone-8'}] bubble_sort(elements,'transaction_amount') print(elements) bubble_sort(elements,'name') print(elements) if __name__ == "__main__": main()
@vation_roofing
3 жыл бұрын
may you please share the code to the exercise the solution is empty
@thamidurandilbandara415
3 жыл бұрын
Amazing tut! Keep it up :D
@AbrarKhan-cc7te
2 жыл бұрын
Can you tell me why are we doing this range(len(elements)-1-i) Why are we doing minus i?
@mattcowan2150
2 жыл бұрын
Looks like the solution for the exercise is no longer available. Can you please fix this? I like being able to compare the solution I come up with to your solution and see ways to improve my program.
@gauravgirase8011
3 жыл бұрын
def bubblesort(elements,param): for i in range(len(elements)-1): for j in range(i+1,len(elements)): data=elements[i] transaction_amount=data[param] data2=elements[j] transaction_amount2=data2[param] if transaction_amount>transaction_amount2: elements[i],elements[j]=elements[j],elements[i] return elements elements = [ { 'name': 'mona', 'transaction_amount': 1000, 'device': 'iphone-10'}, { 'name': 'dhaval', 'transaction_amount': 400, 'device': 'google pixel'}, { 'name': 'kathy', 'transaction_amount': 200, 'device': 'vivo'}, { 'name': 'aamir', 'transaction_amount': 800, 'device': 'iphone-8'}, ] param="name" result=bubblesort(elements,param) print(result)
@akshaykumaredayilliam8708
4 жыл бұрын
Sir, please continue with deep learning series
@codebasics
4 жыл бұрын
Yes I am making it
@ranu__12
4 жыл бұрын
Is there any Problem in using a,b= b,a concept in python for swapping two values ?? I am asking about internal memory management of python ... Would this operation require more memory than creating a temp variable or less ?
@josbinsimon4786
4 жыл бұрын
It's possible
@danyalshah7009
2 жыл бұрын
how to check for differnet array sizes the time complexity using time function
@meralmaradia4774
2 жыл бұрын
Hello Sir, can you please create a video developing of project using only DSA ?
@namratavidolkar4426
3 жыл бұрын
Thank You
@codebasics
3 жыл бұрын
You're welcome
@jsairam8954
3 жыл бұрын
Solution link for the exercise problem is given by you., is not responding.. Pls provide the solution.. Thank you sir
@AMM2012
2 жыл бұрын
Interesting on the way how teach it
@madhurireddy7418
3 жыл бұрын
thanks
@joxa6119
10 ай бұрын
why it is not if swapped, instead of if not swapped?
@soufyanr3745
3 жыл бұрын
Hi, can you maybe do a video on space complexity? appreciate it!
@lovelytyagi1041
3 жыл бұрын
Bhae Thanku
@zihaojiao1304
4 жыл бұрын
what IDE are u using? seems so efficient
@codebasics
4 жыл бұрын
Pycharm community edition. It is free
@zhengxijiang4087
2 жыл бұрын
what is 'not swapped' mean? swapped is a boolean? get stucked here
@jyotiphulwariya6723
3 жыл бұрын
def sorti(lst): size=len(lst) while lst!=sorted(lst): swap=False for i in range(size - 1): if lst[i] > lst[i + 1]: s = lst[i] lst[i] = lst[i + 1] lst[i + 1] = s swap=True if not swap: break return lst a=[9,2,12,4,45,56,1,2,3,90,0] print(sorti(a))
@naveenchahar8074
3 жыл бұрын
hey Jyoti I can understand if your using sorted(lst) then what' the point of using bubble sort. In that case your are sorting list with sorted and then you comparing sorted list with array/list. which results in double time complexity
@sobersabin
3 жыл бұрын
we can do this is one line.why you are using long code.its useless(sorted(element,key=lambda x:x['transaction_amount']))
@Rajkumar-vc2pg
3 жыл бұрын
condition is we have to do with out using built in functions
@mxolisimafu9902
3 жыл бұрын
Can I have solutions to the assignments
@vivekkumar-fe1xr
3 жыл бұрын
exercise solution is not there
@syedtajamalihsanattari7158
10 ай бұрын
Keya ye Hindi main b hai
@shefalishetty6263
3 жыл бұрын
i cant find solution ..help me
@manchitmadan5599
3 жыл бұрын
def bubble_sort_by_key(arr, key='transaction_amount'): size = len(arr) for i in range(size-1): swapped = False for j in range(size-1-i): if arr[j][key] > arr[j+1][key]: #modified this line only temp = arr[j] arr[j] = arr[j+1] arr[j+1] = temp swapped = True if not swapped: break
@satwikgawas5582
4 жыл бұрын
Hello sir apke Hindi channel pr video upload kijiye
Пікірлер: 87