#70 Python Tutorial for Beginners | Bubble Sort in python | List Sort

  Рет қаралды 482,794

Telusko

Telusko

Күн бұрын

Пікірлер: 393
@nikitasharma2069
@nikitasharma2069 3 жыл бұрын
Btw there is no need to take a temp variable for swapping. Python allows a very easy swapping method, just use: num[ j ] , num[ j+1 ] = num[ j+1] , num[ j ]
@pravintulsijw9513
@pravintulsijw9513 3 жыл бұрын
👍
@FukraInsaanLiveShorts
@FukraInsaanLiveShorts 2 жыл бұрын
I Need help @nikita
@jeelaghera5628
@jeelaghera5628 2 жыл бұрын
he has mentioned this code in his series but he is going with old school approach for who are watching bubble sort directly
@eclinicalWorks29
@eclinicalWorks29 2 жыл бұрын
Thanx ❤️
@rubbish9231
@rubbish9231 2 жыл бұрын
This is why Phython called scripting language. The syntax you using is using sort function underneath .. basically its doing all steps there in bavkground.
@AaryanPakhrani
@AaryanPakhrani 5 жыл бұрын
Did he just call me an Alien?
@david-0
@david-0 4 жыл бұрын
yup
@muhammadilyas2179
@muhammadilyas2179 4 жыл бұрын
i was thinking this in previous video.
@indianyoyoer
@indianyoyoer 4 жыл бұрын
Ya
@ayushjhanwar3696
@ayushjhanwar3696 4 жыл бұрын
But why???
@SktechnicalSumit
@SktechnicalSumit 4 жыл бұрын
He is calling us alien since his first day python lecture.
@shamirroy606
@shamirroy606 3 жыл бұрын
This guys should've been our university teacher. He's so good in explaining complex topics. Thanks a lot Navin Reddy.
@KeremAli-cm3pj
@KeremAli-cm3pj 2 ай бұрын
he wouldve called his students aliens.
@g17choudhary
@g17choudhary 5 жыл бұрын
we can directly swap the values no need to temp variable if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j]
@Sachin_Kumar-bn1ql
@Sachin_Kumar-bn1ql 4 жыл бұрын
haha...>> a,b=b,a
@shubhlaabh6342
@shubhlaabh6342 4 жыл бұрын
Yea, it can be done
@himanshurajput8603
@himanshurajput8603 4 жыл бұрын
but you can only do it in python
@adirajsingh6738
@adirajsingh6738 4 жыл бұрын
Himanshu Rajput this is a python course, that’s the whole point lol
@srishtiagarwal3471
@srishtiagarwal3471 4 жыл бұрын
I guess sir is trying to tell the common method of bubble sort rather than just telling how to do this in python
@codewithenthronekingsley
@codewithenthronekingsley Ай бұрын
Navin you are just exceptional. I have been cracking my head about this up until now I watched this tutorial. It strange when some tutors claim they teach to beginners and use complex words. Thank you Navin
@RebeccaNamiya
@RebeccaNamiya 9 ай бұрын
This is the best bubble explanation I have heard in my research. Keep it up . Good work 👍🏾
@shenkuulover
@shenkuulover 3 жыл бұрын
Your editing and speaking skills are amazing. Straight to the point and really showcases what you need to understand. Good job!
@nellaiappan8969
@nellaiappan8969 4 жыл бұрын
It had been very very useful for my son during lockdown Thank you sir😊☺️
@parthbhodia9575
@parthbhodia9575 3 жыл бұрын
This is a really good explanation. I can suggest you to use while loop as well to break out of the for loop if the items in the list are already sorted maybe in the 2nd or 3rd iteration. In that case you will not need to loop through n times.
@gunasekaranguna1888
@gunasekaranguna1888 Жыл бұрын
def Bubble_sort(n): for i in range(len(n)-1,0,-1): for j in range(i): if n[j]>n[j+1]: n[j],n[j+1]=n[j+1],n[j] print(n) c=int(input("Enter the number of elements in list:")) n=[] for k in range(c): d=int(input("Enter an value:")) n.append(d) print(n) print("The sorted list is",Bubble_sort(n)) "small modification"
@harshaddaingade9784
@harshaddaingade9784 4 жыл бұрын
def sort(nums): for i in range(len(nums) - 1, 0, -1): for j in range (i): if nums[j] < nums[j + 1]: continue else: nums[j+1], nums[j] = nums[j], nums[j+1] nums = [5, 8, 9, 71, 10, 2,589,1,0] sort(nums) print(nums)
@glorysonhorace3265
@glorysonhorace3265 2 жыл бұрын
Telusko, you really deserve a thumbs up. DSA never gets easier than this!!!
@pratikb8131
@pratikb8131 4 жыл бұрын
What's difference between bubble and insertion sorting
@sagnikray5391
@sagnikray5391 5 жыл бұрын
sir, pls make a video on insertion sort
@sreekanthk9412
@sreekanthk9412 5 жыл бұрын
Instead of using 3rd variable directly we can swap two values nums[j],nums[j+1]=nums[j+1],nums[j]
@abdulfareed2585
@abdulfareed2585 3 жыл бұрын
Hi telusko. The outer loop and inner loop s range is a bit confusing for me. I just made the range as simple and it works but IDK whether is this right or not! def sort(nums): for i in range(len(nums)-1): for j in range(len(nums)-1): if(nums[j]>nums[j+1]): temp = nums[j] nums[j] = nums[j+1] nums[j+1] = temp return nums nums = [9,0,1,8,2,7,3,12,5] result = sort(nums) print(result)
@muhsinshah6502
@muhsinshah6502 5 жыл бұрын
#Some changes applied def sort(list): for i in range(len(list)-1,0,-1): for j in range(i): if list[j] > list[j+1]: #look here list[j],list[j+1] = list[j+1],list[j] nums = [4,7,3,6,2,3,1] sort(nums) print(nums)
@EritreanGamerOfficial
@EritreanGamerOfficial 2 жыл бұрын
i did it like this . it works def bubbleSwap(lst): x, y = 0, 0 h = 0 while h < len(lst): for i in range(1,len(lst)): if lst[i - 1] > lst[i]: x, y = lst[i - 1], lst[i] lst[i - 1] = y lst[i] = x h += 1 return lst
@kapilsingh7232
@kapilsingh7232 3 жыл бұрын
How we are getting the sorted values as we are not returning values from sort function?
@zakiasmaa6834
@zakiasmaa6834 Ай бұрын
I want to express my heartfelt gratitude for all the effort you put into simplifying the topics. Your presence and the way you explain things in the videos bring us joy and radiate positive energy. I hope you continue in this way, and I wish you all the best in everything you do.
@telugu_rockzz
@telugu_rockzz 2 күн бұрын
Are you a girl?
@arvitech7419
@arvitech7419 5 жыл бұрын
Sir I have a doubt I assumed that a=bin(7) type(a) o/p Then I assume a=0b111 type(a) o/p = How sir both a= bin(7) = 0b111 are equal. But how that is str it is int becz both of the value is 0b111
@akhilkrishna5282
@akhilkrishna5282 3 жыл бұрын
Navin can we do it this way? - we create a empty list and do linear search for the greatest value or lowest value and append it to the empty list and remove it from the original list .....do this a few more times and the original list becomes empty and the empty list becomes sorted....i tried and it worked so i thought commenting would help other programmers get different ideas on how to solve the same problem...
@vintage-flix-movies
@vintage-flix-movies 5 жыл бұрын
python is one line code lang so swap will be num[j],num[j+1]=num[j+1],num[j]
@bonysmoke9190
@bonysmoke9190 5 жыл бұрын
Maybe in some cases it will work, but not always. What this "line of code" does is it reverses a list and you get a something like this : list = [3,2,5,1] - before sorting, and after reversing it, you get list = [1,5,2,3]. If i'm not right, please, let me know :)
@pranavrk9752
@pranavrk9752 3 жыл бұрын
@@bonysmoke9190 it works in all cases dude. its a python one liner. Because of the way python is build there are tons of one liner, In this case the in the video he use an extra variable temp and 3 lines of code, which can be done with the one liner.
@isaachossain2807
@isaachossain2807 3 жыл бұрын
He was probably trying to teach an algorithm that would apply to all programming languages where a temporary variable is required for swapping. Not all programming languages will support a,b=b,a.
@DeepakKumar-uz4xy
@DeepakKumar-uz4xy 5 жыл бұрын
why take second for loop. can't we use if function directly by direct puttind swap function. for i in range(len(list)): if list[i]>list[i+1]: list[i], list[i+1] = list[i+1], list[i]
@sagarrao79
@sagarrao79 5 жыл бұрын
if we use only one for loop, only one value sorted to last like below [3, 5, 6, 2, 4, 8] to repeat same thing we need to use second for loop. yes we can use swap a,b= b,a def sort(list): for i in range(len(list)-1,0,-1): for j in range(i): if list[j] > list[j+1]: list[j],list[j+1]=list[j+1],list[j] nums=[5,3,6,8,2,4] sort(nums) print(nums)
@alexw.e.1390
@alexw.e.1390 5 жыл бұрын
@@sagarrao79 Please explain this to me: for i in range(len(list)-1,0,-1): I am so confused as to how this works and can't seem to figure it out on my own. Thanks
@navinyadav9693
@navinyadav9693 5 жыл бұрын
@@alexw.e.1390we need to check the values from start till end. when i=5(in this program) j runs from 0 till 5 and the largest value, i.e 8 gets shifted to last place. now i becomes 4( since -1) and j runs from 0 to 4 and the next largest value gets shifted to second last place. this goes on until nums is sorted. i is taken in reverse so that j can check until last value. if this didn't help please debug the program. It will help you understand what is happening step by step.
@chandrashekhartigercharla1633
@chandrashekhartigercharla1633 3 жыл бұрын
Finally I did with one loop.. Num=[3,6,2,16,11,17,8] Def sort(list): For i in range(len(num)-1): If num[I] > num[I+1]: Num[I],num[I+1] = num[I+1],num[I] Sort(num) Sort(num) Print (num)
@sharathnani6406
@sharathnani6406 2 жыл бұрын
This is just sort not a bubble sort
@xathunalwarrior8287
@xathunalwarrior8287 4 жыл бұрын
why to make swapping complicated, when you can do this: a,b=b,a
@nawazmalik5435
@nawazmalik5435 4 жыл бұрын
U have one glass of juice And a cup of tea If u want to shift (swap) both . U need a cup called temp U put juice in temp Then tea to empty juice glass And finally juice to cup .
@EylulTurksever
@EylulTurksever 4 жыл бұрын
@@nawazmalik5435 no you don't. in python, you can do it without an extra cup. Xanthunal Warrior's way is correct and better.
@kaushalJainer
@kaushalJainer 4 жыл бұрын
lol he also knew that, its just in other languages u dnt have the luxary of swapping this way thats why, once u know the logic u can implement it anywhere you want
@madhavbhardwaj2527
@madhavbhardwaj2527 3 жыл бұрын
@@kaushalJainer It is but than you have to remember the variables which have been swapped which will become a more complicated thing. As you have to put b where you are putting a after swapping and vice versa.... If you are putting a simple logic it is ok and will definitely run on any python software...
@anushkasingh1728
@anushkasingh1728 3 жыл бұрын
Due to the differences in Cs and Ip
@chinmaydas4053
@chinmaydas4053 6 жыл бұрын
Nice sir.. waiting for your video..
@balajiverma.sc-arn-2536
@balajiverma.sc-arn-2536 2 жыл бұрын
Sir, you are the best teacher, but why do you tell programmers "Aliens"? Pls explain
@rohitmalap5599
@rohitmalap5599 4 жыл бұрын
in the function sort, nums is local variable and is valid only for that particular suite. So how does changes in nums in sort function will reflect in nums outside sort? Could you please explain this?
@DeepakKumar-cq6jm
@DeepakKumar-cq6jm 2 жыл бұрын
Num is passed in sort so we can use it as local variable
@gaurikosamkar382
@gaurikosamkar382 4 жыл бұрын
I didn't understand the concept of range varying from -1to 0 and then again -1
@batteryjuicy4231
@batteryjuicy4231 2 жыл бұрын
you could also have a variable = 0 at the start of every iteration and inciment it by 1 when you swap, therefore if at the end of an iteration the variable is 0 means the list is sorted and you don't have to try to sort the rest of the already sorted list
@hamidfarooq7242
@hamidfarooq7242 5 жыл бұрын
you are amazing took me 7 mins to understand what i have been trying to understand for days
@memesv3.093
@memesv3.093 4 жыл бұрын
Here's the easiest way: arr = [] a = int(input("Enter the no of elements")) for i in range(a): x = int(input()) arr.append(x) for i in range(a-1): for j in range(a-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] print("Sorted array is:", arr)
@tatapramod277
@tatapramod277 4 жыл бұрын
could u please explain the a-i-1 part please
@jeetsutaria6802
@jeetsutaria6802 5 жыл бұрын
thank you sir . tomorrow is my practicals and i have learned from from this video than i have learnt in my entire semister
@Rohan-c6y
@Rohan-c6y 7 ай бұрын
throw back to 4 years ago when you were learning from this video any outputs now? what are you doing now after 4 years are you a full fledged python developer
@shahvipul7459
@shahvipul7459 4 жыл бұрын
def Bubble(list_a): indexing_length = len(list_a) - 1 sorted = False while not sorted: sorted = True for i in range(0, indexing_length): if list_a[i] > list_a[i + 1]: sorted = False list_a[i], list_a[i + 1] = list_a[i + 1], list_a[i] return list_a print(Bubble([5, 3, 8, 6, 7, 2]))
@bedbyashlamichhane1541
@bedbyashlamichhane1541 4 жыл бұрын
we could use :am = [5,8,2,4,8,1] aw = sorted(am) print(aw)
@umxng
@umxng 4 жыл бұрын
4:00
@obbinenireddy4184
@obbinenireddy4184 6 жыл бұрын
Thank you sir .....sir will you cover all data structure concepts????
@tusharkaushik9554
@tusharkaushik9554 5 жыл бұрын
No sir will not
@ruomengtian4202
@ruomengtian4202 4 жыл бұрын
@@tusharkaushik9554 lol
@AmarjeetSingh-ammy
@AmarjeetSingh-ammy 6 жыл бұрын
Eagerly waiting sir, You are awesome,, I'm going to give you the name "KNOWLEDGE STACK " love from delhi
@shubhampawar9745
@shubhampawar9745 4 жыл бұрын
Also Using sorted function N=[1,4,5,5,7, 8,7,5,9,7] Print (sorted(N))
@shubhampawar9745
@shubhampawar9745 4 жыл бұрын
Python provide us inbuilt function
@sameerroshan9542
@sameerroshan9542 8 ай бұрын
for the outer loop you can also do: for i in reversed(range(len(nums))): and for swapping you can do this: if nums[j] > nums[j+1]: nums[j], nums[j+1] = nums[j+1], nums[j]
@chamarthiyashwanth4060
@chamarthiyashwanth4060 3 жыл бұрын
def bubble_sort(seq): min_value = 0 for i in range(len(seq)-1): for j in range(i): if seq[j] > seq[j+1]: seq[j],seq[j+1] = seq[j+1],seq[j] return seq is this considered as bubble sort, as in this the sorting is done by taking out the minimum values just like selection sort but with more iterations.
@jackwan358
@jackwan358 Жыл бұрын
It save me the day to learn this in 10mins! Million thanks!!
@tanujgandhi8938
@tanujgandhi8938 4 жыл бұрын
unable to understand the -1 , 0 ,-1
@anastasiagavrilita6567
@anastasiagavrilita6567 4 жыл бұрын
You are a savior in every single way! (I refer to all of your tutorials!) So grateful that you are doing these tutorials!
@SachinParasharny
@SachinParasharny 4 жыл бұрын
I do the same. He is amazing
@எதுக்கு-த8ண
@எதுக்கு-த8ண 3 жыл бұрын
why should we put -1in end part of the range declaration (starting)
@Rajadahana
@Rajadahana 2 жыл бұрын
We have covered swapping in an earlier lesson in detail. There we discussed 3 methods as I remembered. So it is time to put that knowledge to work, without using a 3rd variable. (I learnt this from you) nums[j], nums[j+1] = nums[j+1], nums[j]
@shreyagodson243
@shreyagodson243 2 ай бұрын
Thank you for showing in user defined module 😊
@aakarshjain7026
@aakarshjain7026 6 жыл бұрын
Can you give tutorial of c++ for beginners
@shreenidhis2496
@shreenidhis2496 4 жыл бұрын
Hi Sir, why this code needs to return ?? def fact(n): f=1 for i in range(1,n+1): f=f*i return f x=5 res=fact(x) print(res) and y bubble sort doesn't need return??
@yaminipriya3742
@yaminipriya3742 4 жыл бұрын
i didn't understand y he used that range(-1,0,-1) anyone plz explain
@yaminipriya3742
@yaminipriya3742 4 жыл бұрын
Go to Amuls academy and search bubble sort you will understand in that
@sourabhhukkeri8286
@sourabhhukkeri8286 3 жыл бұрын
Wth you answered your own question
@subhamoydey3867
@subhamoydey3867 5 жыл бұрын
sir you solve my doubt in just 7 minutues just like laminar flow of water
@saqulainkhan6717
@saqulainkhan6717 3 жыл бұрын
Sir do you have live classes for ds in python or notes kindly reply
@akshaykatta3606
@akshaykatta3606 4 жыл бұрын
# Bubble Sort class Sorting: def __init__(self, list): self.list = list def sort(self): for i in range(len(self.list)-1): for j in range(i+1, len(self.list)): if self.list[i] > self.list[j]: self.list[i], self.list[j] = self.list[j], self.list[i] return list1 list1 = [] number = int(input("Enter Size of List: ")) for i in range(number): print("Enter", (i+1), "element:", end="") list1.append(int(input())) print(" List before Sorting: ", end="") for i in list1: print(i, end=" ") s1 = Sorting(list1) list1 = s1.sort() print(" List After Sorting: ", end="") for i in list1: print(i, end=" ")
@manojs2546
@manojs2546 4 жыл бұрын
Why you using this much process? simply we can do nums.sort() print(nums) by it it sort very simple way ,please you may clarify it.
@sahilsurve5361
@sahilsurve5361 4 жыл бұрын
Navin sir actually have explained what happens inside 'nums.sort()' function It was d basic method to understand how the built in functions like 'nums.sort()' are created There is one more way to swap: a,b=b,a
@MAVERIKTOFA
@MAVERIKTOFA 3 жыл бұрын
def sort(nums): for index1,value1 in enumerate(nums): for index2,value2 in enumerate(nums): if value1
@TANUJAS-y6o
@TANUJAS-y6o 2 ай бұрын
li=[5,3,8,6,7,2] for i in range(len(li)): for j in range(len(li)-1): temp=0 if li[j]>li[j+1]: li[j],li[j+1]=li[j+1],li[j] print(li)
@piyushvaidya3128
@piyushvaidya3128 3 жыл бұрын
For outer loop can we take range(0,len(nums)-1,1)?
@luzzaro4158
@luzzaro4158 Жыл бұрын
It won't work that way
@vishnuvardhanreddy8584
@vishnuvardhanreddy8584 5 жыл бұрын
sir u r awsomee i love this python tutorials and i shared to my friends
@persianleague399
@persianleague399 Жыл бұрын
why not just use nums.sort() ? is it just for practice purpose? or it has different uses in real projects?
@viveksundaray6837
@viveksundaray6837 3 жыл бұрын
shouldn't it be: for j in range(i+1) but sir has written for j in range(i) which means that if i = 5 then the value of j will be 4 instead of four ??
@kartik.sharma.22
@kartik.sharma.22 3 жыл бұрын
sir please tell me whether my this program is right or not it is giving right output but please check my method def sort(val): for i in range(len(val)): for j in range(len(val)-1): if val[j] > val[j+1]: temp = val[j] val[j] = val[j+1] val[j+1] = temp return val n = int(input("Enter the size of array ")) val = array('i', []) for i in range(n): value = int(input("Enter the value ")) val.append(value) sort(val) print(val)
@giuseppepala8668
@giuseppepala8668 4 жыл бұрын
I've found more elegant to substitute lines 6, 7 and 8 with list[j], list[j + 1] = list[j + 1], list[j] (i've learned that from my favourite Python on-line teacher 😉)
@jjiiee9636
@jjiiee9636 4 жыл бұрын
It works man thanks, its like a short cut
@creativebeing1108
@creativebeing1108 4 жыл бұрын
Learn code academy
@ikrajmohammad8999
@ikrajmohammad8999 5 жыл бұрын
Ots good work sir, keep.making more videos on python
@gamesgames3318
@gamesgames3318 2 жыл бұрын
Im dumb at coding so this is a life saver when I can't understand certain parts of the code.
@abhiprit20
@abhiprit20 3 жыл бұрын
What if instead of list, I used tuples, dictionary as a input data structures, so time complexity will remain same or change?
@hruthik1834
@hruthik1834 3 жыл бұрын
This can be done through the normal sorting method which u explained in the lists concept
@sirikilohit2077
@sirikilohit2077 2 жыл бұрын
In Fact, We don't need to type complex logic: for i in range(len(nums)-1,0,-1): for j in range(i): if nums[j] > nums[j+1]: nums[j],nums[j+1] = nums[j+1],nums[j] Instead we can type like this: for i in range(len(nums)-1,0,-1): for j in range(i): if nums[j] > nums[j+1]: nums[j],nums[j+1] = nums[j+1],nums[j]
@kushagragupta4381
@kushagragupta4381 4 жыл бұрын
Mind blowing explanation!
@johndu9255
@johndu9255 4 жыл бұрын
Also isn't there is a build in keyword "sort" ? Should we change the def to something else ?
@sandeeppareek8941
@sandeeppareek8941 4 жыл бұрын
FOR SORTING IN ASCENDING ORDER ls = [7, 3, 3, 6, 5, 9, 2] ls.sort() print(ls)
@avinashtammali6130
@avinashtammali6130 4 жыл бұрын
amazing
@pritishchavan1671
@pritishchavan1671 2 жыл бұрын
very good
@sumitgupta-wf4db
@sumitgupta-wf4db 6 жыл бұрын
Sir you are giving my quarry answer Thanks for that I have find my answer without your help
@vaishalirathi5530
@vaishalirathi5530 3 жыл бұрын
I tried to import both module in one file first I sort the list then find particular value it gives correct answer but position value is not coming right can someone help me in tha code is same as in video for both import file from Binarysearch import* from Bubblesort import* list=[4,6,1,3,5,9] sort(list) print('list=',list) n=9 if search(list,n): print('Found',pos) else: print('Not Found')
@gnanendraprakash847
@gnanendraprakash847 5 жыл бұрын
Sir, why don't we use nums[j] , nums[j+1] = nums[j+1] , nums[j] instead of t=a a=b b=t for swapping purpose.
@telugucinemastudio1222
@telugucinemastudio1222 3 жыл бұрын
Thanks bro this video is very helpful for me. I am studying engineering Would you suggest some tips to enhance my coding and communication skills.
@akshay4081
@akshay4081 5 жыл бұрын
No need of temp..Directly swapping def sort(lst): for i in range(len(lst)-1,0,-1): for j in range(i): if lst[j]>lst[j+1]: lst[j],lst[j+1]=lst[j+1],lst[j] print[lst] lst=[3,2,6,4,9,7,5] sort(lst)
@abhijeetshikharvlog1444
@abhijeetshikharvlog1444 5 жыл бұрын
Hey i will join your course but i have an one question can you teach me data structure in python all the topic sir
@moazelsawaf2000
@moazelsawaf2000 5 жыл бұрын
Great topics and very good explanation ❤
@prasadshete781
@prasadshete781 2 жыл бұрын
Hey well explained . But I didn't get range(numa)-1,0,-1 ?? What it does
@raviteja87
@raviteja87 3 жыл бұрын
Included 0 in the list but wrong o/p is coming [1,0,2,3,] like this it is coming why is it like this
@srirajaniswarnalatha2306
@srirajaniswarnalatha2306 3 жыл бұрын
is there any built-in function for bubble sorting please reply navin
@sapnajain1332
@sapnajain1332 5 жыл бұрын
Sir , I m want to download Python Interpreter but it's version is 3.7.1 which is the latest one . Your videos are based on the version 3.7.0 . I want to ask you that it will create difference or not ❓
@riadhasan3683
@riadhasan3683 4 жыл бұрын
output is [3, 2, 4, 6, 7, 7, 65] what is the problem.. ?? def sort(nums): for i in range(len(nums)): for j in range(i): if nums[j]>nums[j+1]: temp = nums[j] nums[j]=nums[j+1] nums[j+1]=temp nums=[7,4,3,6,2,7,65] sort(nums) print(nums)
@withharshvadhiya
@withharshvadhiya 2 жыл бұрын
def sort(a): for i in range(len(a)-1,0,-1): for j in range(i): if a[j] > a[i]: a[i], a[j] = a[j], a[i] this also works same : )
@anuragtiwari9793
@anuragtiwari9793 3 жыл бұрын
If there is an inbuilt function to sort, then why. Use these algorithms???
@misan2002
@misan2002 4 жыл бұрын
How would i do this for lists with elements which are made up if both strings and integers? Please help me
@rajshah1797
@rajshah1797 5 жыл бұрын
hello sir, i have one question. how did the nums got updated? we didn't returned it from the function and neither we used globals in the function.
@seyedfayaz
@seyedfayaz 4 жыл бұрын
Is this correct ? Please urgent a = [] number = int(input("Please Enter the Total Number of Elements : ")) for i in range(number -1): for j in range(number - i - 1): if(a[j] > a[j + 1]): temp = a[j] a[j] = a[j + 1] a[j + 1] = temp print("The Sorted List in Ascending Order : ", a)
@AmazingVideoGaming
@AmazingVideoGaming 6 жыл бұрын
Plz make a video on pygame. Plz sir🙏🙏🙏
@ankushsarkar1746
@ankushsarkar1746 5 жыл бұрын
Flask or django?
@Skaxarrat
@Skaxarrat 5 жыл бұрын
pygrame, I guess
@apurbasarkar6918
@apurbasarkar6918 3 жыл бұрын
while running the code you didn't call the function, you just used the built-in sorted function
@vipulchauhan2611
@vipulchauhan2611 4 жыл бұрын
thank you so much sir.i will be thankful to you.with the help of you i easily learn python
@isaachossain2807
@isaachossain2807 3 жыл бұрын
Navin Reddy, you are my hero.
@Perplexedsouvik
@Perplexedsouvik 4 жыл бұрын
Sorry, but I got confused in this. Specially the outer loop logic. Can you please elaborate using outer and inner loops.
@arshgupta5737
@arshgupta5737 4 жыл бұрын
def sort(self): for i in range(a-1,0,-1): for j in range(i): if list[j]>list[j+1]: temp=list[j] list[j]=list[j+1] list[j+1]=temp a=int(input("Enter the no. of elements you want to enter in the list ")) list=[] for i in range(a): li=int(input()) list.append(li) print("Unsorted list is: ",list) sort(list) print ("Sorted list is: ",list)
@shams6474
@shams6474 3 жыл бұрын
vowwww.....I never understood it i college but u made my life easy.
@KeremAli-cm3pj
@KeremAli-cm3pj 2 ай бұрын
*wowwww..... I never understood it in college but you made my life easy.
@justbelieve9754
@justbelieve9754 3 жыл бұрын
Just outstanding. Love from Pakistan.
@rakshitrakshit6022
@rakshitrakshit6022 3 жыл бұрын
why to make sorting so complex when you can do this print(sorted(nums))
@Hassam_Haider
@Hassam_Haider 2 жыл бұрын
thank you very much Sir really, you helped me so much with this
@anuthomas5184
@anuthomas5184 2 жыл бұрын
I am searching for all the sorting algorithms in java telusko. But it's getting python... Can u provide the Bubble sort link in java. Now I became an addict of telusko java learning. It's really Amazing
@Game-nr3sr
@Game-nr3sr Жыл бұрын
check in another YT playlist
@bharathvaj2760
@bharathvaj2760 4 жыл бұрын
5:14 sir we are going from 5 to 0 right?
@sagardixit8432
@sagardixit8432 4 жыл бұрын
yes bro
@abhinavshaw4656
@abhinavshaw4656 3 жыл бұрын
0 is for index no. But here we consider as 1 for himan understanding
@sattwikdas3148
@sattwikdas3148 5 жыл бұрын
Can u please make a video on bubble sort in c
7.3 Bubble Sort Algorithm| Data Structures Tutorials
35:36
Jenny's Lectures CS IT
Рет қаралды 1,5 МЛН
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 117 МЛН
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 125 МЛН
大家都拉出了什么#小丑 #shorts
00:35
好人小丑
Рет қаралды 96 МЛН
POV: Your kids ask to play the claw machine
00:20
Hungry FAM
Рет қаралды 17 МЛН
Python Decorators in 15 Minutes
15:14
Kite
Рет қаралды 442 М.
No, Einstein Didn’t Solve the Biggest Problem in Physics
8:04
Sabine Hossenfelder
Рет қаралды 295 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 652 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 306 М.
Bubble Sort - Data Structures & Algorithms Tutorial Python #14
15:09
How to: Work at Google - Example Coding/Engineering Interview
24:02
Life at Google
Рет қаралды 7 МЛН
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 117 МЛН