Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
linear search completed
  • Loading branch information
Hunter315 committed Jan 17, 2019
commit 1fd5bdf8902a67cc554ab294dfee87abcae845e2
11 changes: 11 additions & 0 deletions project/iterative_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,16 @@ def bubble_sort( arr ):

# STRETCH: implement the Count Sort function below
def count_sort( arr, maximum=-1 ):
m = maximum + 1
count = [0] * maximum

for a in arr:
count[a] = count[a] + 1
i = 0
for a in range(m):
for c in range(count[a]):
arr[i] = a
i = i + 1


return arr
3 changes: 3 additions & 0 deletions project/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
def linear_search(arr, target):

# TO-DO: add missing code
for i in range(len(arr)):
if arr[i] == target:
return i

return -1 # not found

Expand Down