![](/style/images/good.png)
![](/style/images/bad.png)
I just needs some guidance please
source link: https://www.codeabbey.com/index/forum_topic/c771b6a99544f1d04ef68279b8970ceb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
I just needs some guidance please
Back to Problem Solutions forum
So long story short, I was excited to see the bubble sort task in the names as bubble sort is one of the functions that costed me the most to learn. But after sometime typing it I got the jist of it.
The issue is that the way I do this sort is not actually counting properlly the number of passes:
def bubblesort(array):
passCounter = 0
swapsCounter = 0
for i in range(0, len(array)):
passcounter += 1
for j in range(i, len(array)):
if array[i] > array[j]:
temp = array[i]
array[i] = array[j]
array[j] = temp
swapscounter += 1
solution = []
solution.append(passCounter)
solution.append(swapscounter)
return solution
I definetly know the issue is that I am not counting the passes as they expect me to, but then I don't know how should I do it, I need some help please.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK