davegimo

selection sort non in place

Oct 31st, 2020
1,268
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. l = [4,5,9,1,13,2,0,8]
  2. ordinata = []
  3.  
  4. print(l)
  5.  
  6. while len(l) > 0:
  7.     minimo = l[0]
  8.    
  9.     for element in l:
  10.         if element < minimo:
  11.             minimo = element
  12.  
  13.     print("minimo corrente = " + str(minimo))
  14.     l.remove(minimo)
  15.     ordinata.append(minimo)
  16.     print("l = " + str(l))
  17.  
  18.  
  19. print("----")
  20. print("ordinata = " + str(ordinata))
  21.    
  22.  
RAW Paste Data