Initial transfer of larger repo from git. IF full history and branches are needed must go to github at https://github.com/DulcisL/CCUCoding.git
This commit is contained in:
commit
c09ce40be0
4048 files changed
+603256
No files matched your search
@@ -0,0 +1,20 @@
|
||||
class Search():
|
||||
|
||||
|
||||
def linearSearch(self, searchList, length, key):
|
||||
for i in range(0, length):
|
||||
if (searchList[i] == key):
|
||||
return i
|
||||
return -1
|
||||
|
||||
def binarySearch(self, searchList, low, high, key): #user-defined function
|
||||
if high >= low: #check base case
|
||||
mid = (high + low) // 2
|
||||
if (searchList[mid] == key):
|
||||
return mid
|
||||
elif (searchList[mid] > key):
|
||||
return self.BinarySearch(searchList, low, mid - 1, key)
|
||||
else:
|
||||
return self.BinarySearch(searchList, mid + 1, high, key)
|
||||
else:
|
||||
return -1
|
||||
Reference in new issue
Block a user