Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import unittest
  2.  
  3. x= [10,20,15,48,63,52,15,44]
  4.  
  5. class SortingALgorithm(unittest.TestCase):
  6. def __init__(self):
  7. pass
  8.  
  9. def insertionSort(self,A):
  10. for j in range(2,len(A)):
  11. key = A[j]
  12. i = j-1
  13. while i>0 and A[i] > key:
  14. A[i+1] = A[i]
  15. i=i-1
  16. A[i+1]=key
  17. return A
  18.  
  19. def checkAlgo():
  20. value= [10, 15, 15, 20, 44, 48, 52, 63]
  21. self.assertListEqual(value,self.insertionSort(x))
  22.  
  23. sorting = SortingALgorithm()
  24. if __name__=="__main__":
  25. unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement