tankdthedruid

selectionSort.py

Jul 3rd, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1.  
  2. import random
  3.  
  4. N = 1000
  5. list1 = []
  6.  
  7. for i in range(0, N):
  8.     list1.append(random.randint(0, N-1))
  9.  
  10. list2 = list(list1)
  11. print '\nRandom Integer String:\n\n', list2
  12.  
  13. # Selection Sort
  14. for i in range(0, len (list2)):
  15.     min = i
  16.     for j in range(i + 1, len(list2)):
  17.         if list2[j] < list2[min]:
  18.             min = j
  19.     list2[i], list2[min] = list2[min], list2[i]
  20. print '\n\nSorted Integer String:\n\n', list2
Advertisement
Add Comment
Please, Sign In to add comment