diff --git a/Knapsack.py b/Knapsack.py index 9a84edc..14800dd 100644 --- a/Knapsack.py +++ b/Knapsack.py @@ -1,4 +1,6 @@ #!/usr/bin/python3 + +"""This program uses the greedy approach to solve the knapsack problem""" import mysql.connector import datetime capacity=int(input("Enter the capacity of your knapsack:\n")) diff --git a/MergeSort.py b/MergeSort.py index eee084a..673f739 100644 --- a/MergeSort.py +++ b/MergeSort.py @@ -3,9 +3,9 @@ import datetime a = datetime.datetime.now() def mergeSort(arr): - if len(arr) >1: + if (len(arr) >1): mid = len(arr)//2 - L = arr[:mid] + L = arr[0:mid] R = arr[mid:] mergeSort(L) @@ -13,7 +13,7 @@ def mergeSort(arr): i = j = k = 0 - while i < len(L) and j < len(R): + while (i < len(L) and j < len(R)): if L[i] < R[j]: arr[k] = L[i] i+=1 @@ -23,12 +23,12 @@ def mergeSort(arr): k+=1 - while i < len(L): + while (i < len(L)): arr[k] = L[i] i+=1 k+=1 - while j < len(R): + while (j < len(R)): arr[k] = R[j] j+=1 k+=1