Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = [20,40,90,50,60,70,80,110,100,30]
- def bubbleSort(arr):
- isSorted = False
- while not(isSorted):
- for i in range(len(arr) - 1):
- for j in range(len(arr) - 1 - i):
- if arr[j] > arr[j+1]:
- what[j], what[j+1] = what[j+1],what[j]
- else:
- isSorted = True
- return what
- def selectionSort(what):
- for i in range(len(what)):
- minpos = 0
- for j in range(i,len(what)):
- if what[j] < what[minpos]:
- minpos = j
- temp = what[i]
- what[i],what[minpos] = what[minpos],temp
- what.append(what[0])
- what.pop(0)
- return what
- def insertionSort(what):
- for i in range(len(what)):
- element = what[i]
- pos = i
- while (pos > 0 and what[pos-1] > element):
- what[pos] = what[pos-1]
- pos = pos - 1
- what[pos] = element
- return what
- def binarySearch(arr,target):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement