Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions BinarySearch.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
5 changes: 5 additions & 0 deletions Knapsack.py
Original file line number Diff line number Diff line change
@@ -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"))
Expand Down