Created
December 9, 2011 02:50
-
-
Save yasith/1449920 to your computer and use it in GitHub Desktop.
CSC108 Dec. 2009 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reverse_linearsearch(v, L): | |
index = len(L) - 1 | |
while index > -1 and L[index] != v: | |
index -= 1 | |
return index | |
def find_all(v, L): | |
li = [reverse_linearsearch(v, L)] | |
while li[-1] != -1: | |
li.append(reverse_linearsearch(v, L[:li[-1]])) | |
return li[:len(li) - 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment