SHARE
TWEET

InsertionSort

michalkowalczyk Dec 3rd, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Nov 19 07:55:01 2018
  4.  
  5. @author: kowamich
  6. """
  7.  
  8. A=[]
  9. from random import randint
  10. for i in range(0,100):
  11.     j=randint(1,100)
  12.     A.append(j)
  13. print(A)    
  14.  
  15. def Insert_sort(A):
  16.     for i in range(1,len(A)):
  17.         klucz = A[i]
  18.         j = i - 1
  19.         while j>=0 and A[j]>klucz:
  20.             A[j + 1] = A[j]
  21.             j = j - 1
  22.         A[j + 1] = klucz
  23.        
  24. Insert_sort(A)
  25. print(A)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top