Largest subarray sum (#1404)

* Insertion_sort

* largest subarray sum

* updated print command

* removed extraspaces

* removed sys.maxint

* added explaination

* Updated function style

* Update largest_subarray_sum.py

* Update i_sort.py

* Delete bogo_bogo_sort.py
This commit is contained in:
anubhav-sharma13
2019-10-22 13:00:11 +05:30
committed by Christian Clauss
parent 4531ea425e
commit ce7faa5a3a
3 changed files with 44 additions and 54 deletions

21
sorts/i_sort.py Normal file
View File

@ -0,0 +1,21 @@
def insertionSort(arr):
"""
>>> a = arr[:]
>>> insertionSort(a)
>>> a == sorted(a)
True
"""
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
arr = [12, 11, 13, 5, 6]
insertionSort(arr)
print("Sorted array is:")
for i in range(len(arr)):
print("%d" % arr[i])