0
How to do bubble sort using python?
10 Respostas
+ 1
u know. why do you ask?
+ 1
okay please LINK your code here
even if buggy.
+ 1
This is how I did it ,tho it wasn't really that easy as I thought it would be!
I knew the logic but implementing it was a challenge!!
https://code.sololearn.com/cETkoID3Q23o/?ref=app
+ 1
This is a pretty standard bubble sort implementation.
Used, Abhay list and a timer to show it may be faster.
Which was already sorted for some reason. Just plug any number list into it.
https://code.sololearn.com/cs6oVDhG8oOq/?ref=app
+ 1
https://docs.python.org/3/library/timeit.html
you can remove it if desired
0
#python 3.7.1
def bubble(x):
if a[len(a)-1]==max(a) and a[0]==min(a):
print(a)
return a
else:
i=0
while i<len(a)-1:
a[i],a[i+1]=a[i+1],a[i]
i=i+1
return bubble(x)
a=[8,6,7,5,1]
a=list(map(bubble,a))
Why error?
0
It is giving error and I asked for any another way to do.
0
Or modification
0
What is the use of time in this?