Update insertionsort.md

This commit is contained in:
Meet Zaveri
2018-02-20 15:03:22 +05:30
committed by GitHub
parent f550102a43
commit 4f4bce9c2e

View File

@ -1,5 +1,23 @@
### Insertion Sort
## Insertion Sort
## Implementation
```python
arr = [] # list to sort
def insertionsort(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i-1
while j>=0 and key < arr[j]:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key
```
### Example
```python
arr = [7,4,9,2,6,3]