Advertisement
EXTREMEXPLOIT

InsertionSort Algorithm

Apr 22nd, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. def InsertionSort(Array):
  2.     for arrayPosition in range (1, len(Array)):
  3.         actualElement = Array[arrayPosition] # Elemento que se compara.
  4.        
  5.         while arrayPosition > 0 and Array[arrayPosition - 1] > actualElement:
  6.             Array[arrayPosition] = Array[arrayPosition - 1]
  7.             arrayPosition -= 1
  8.             Array[arrayPosition] = actualElement
  9.            
  10.     return Array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement