Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #second fixed edition
- from multiprocessing import Process
- import random
- import math
- def switch_item(a,b):
- return b,a
- def bubble_sort(array):
- for i in range(len(array)-1,0,-1):
- for j in range(0, i):
- if array[j] > array[j+1]:
- array[j], array[j+1] = switch_item(array[j], array[j+1])
- #or array[j], array[j+1] = array[j+1], array[j]
- print("Array sorted: ", array)
- def rand_array():
- arrayofrand = list()
- temprand = 1.0
- for a in range(20):
- temprand = random.random()
- arrayofrand.append(math.floor(temprand*1000))
- return arrayofrand
- if __name__ == '__main__':
- p = Process(target=bubble_sort, args=(rand_array(),))
- p.start()
- p.join()
Advertisement
Add Comment
Please, Sign In to add comment