Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1
- def checkAdj(L):
- n = len(L)
- for i in range(n-1):
- print(min(L[i], L[i+1]))
- # 2
- def bubbleSwap(L):
- # every execution will put the largest item to the right-most position
- n = len(L)
- for i in range(n-1):
- if L[i] > L[i+1]:
- temp = L[i+1]
- L[i+1] = L[i]
- L[i] = temp
- # no output since the original array was modified in-place
- # 3
- def bubbleSort(L):
- # do bubble swap for len(L) - 1 times
- n = len(L)
- for j in range(n-1):
- for i in range(n-j-1):
- if L[i] > L[i+1]:
- temp = L[i+1]
- L[i+1] = L[i]
- L[i] = temp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement