Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a=[0,0,1,0,1,2,1,2,2]
- '''
- selection sort:n^2
- 1)bubble sort:n^2
- 2)merge sort :n log n
- 3) O(n)
- '''
- x,y,z=0,0,0
- for i in a:
- if i==0:x+=1
- elif i==1:y+=1
- else:z+=1
- i=0
- while x:
- a[i]=0
- x=x-1
- i=i+1
- while y:
- a[i]=1
- y=y-1
- i=i+1
- while z:
- a[i]=2
- z=z-1
- i=i+1
- print(a)
Advertisement
Add Comment
Please, Sign In to add comment