From 277f933c77dd96b1ea80c61eebfc170fab3f2b22 Mon Sep 17 00:00:00 2001 From: inder5522 <56110745+inder5522@users.noreply.github.com> Date: Sun, 6 Oct 2019 22:18:16 +0530 Subject: [PATCH 1/2] Update BinarySearch.py --- BinarySearch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BinarySearch.py b/BinarySearch.py index d237395..738663a 100644 --- a/BinarySearch.py +++ b/BinarySearch.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import mysql.connector - - +import datetime +a=datetime.datetime.now() def binsearch(array, first, last, element): if(last >= first): mid = (first+last)//2 @@ -32,3 +32,6 @@ def binsearch(array, first, last, element): print("The Roll No is found at the position: " + str(result+1) + " in the Database") else: print("Sorry the Roll No " + str(element) + " is not found in the Database! ") +b=datetime.datetime.now() +c=b-a +print("The time taken to search a rollno. using binary search= ",c) From d0a8412001065fcd5b34422757f87edf26ac2432 Mon Sep 17 00:00:00 2001 From: inder5522 <56110745+inder5522@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:50:12 +0530 Subject: [PATCH 2/2] Update Knapsack.py --- Knapsack.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Knapsack.py b/Knapsack.py index 9a84edc..770e7ef 100644 --- a/Knapsack.py +++ b/Knapsack.py @@ -1,4 +1,9 @@ +#The knapsack problem is: Given a set of items, each with a weight and a value, +#determine the number of each item to include in a collection +#the total weight is less than or equal to a given limit and the total value is as large as possible. + #!/usr/bin/python3 + import mysql.connector import datetime capacity=int(input("Enter the capacity of your knapsack:\n"))