diff options
author | RossTheRoss <mstrapp@protonmail.com> | 2020-04-17 15:54:39 -0500 |
---|---|---|
committer | RossTheRoss <mstrapp@protonmail.com> | 2020-04-17 15:54:39 -0500 |
commit | 48296dc298efbb9fc0778db00106635c901cbf20 (patch) | |
tree | fdfe7e3a2032acd23be6b7977ea1707515fd94f4 | |
parent | commit on master (diff) | |
download | homework-48296dc298efbb9fc0778db00106635c901cbf20.tar homework-48296dc298efbb9fc0778db00106635c901cbf20.tar.gz homework-48296dc298efbb9fc0778db00106635c901cbf20.tar.bz2 homework-48296dc298efbb9fc0778db00106635c901cbf20.tar.lz homework-48296dc298efbb9fc0778db00106635c901cbf20.tar.xz homework-48296dc298efbb9fc0778db00106635c901cbf20.tar.zst homework-48296dc298efbb9fc0778db00106635c901cbf20.zip |
oops
-rw-r--r-- | csci4041/hw3prob2.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/csci4041/hw3prob2.py b/csci4041/hw3prob2.py new file mode 100644 index 0000000..33f36f6 --- /dev/null +++ b/csci4041/hw3prob2.py @@ -0,0 +1,21 @@ +def ADDYHASHSEARCH(T,k): + i=0 + j=0 + s=1 + m=len(T) + while T[j]!=None and i<=m: + j=(h(k)+i)%m + if T[j] is k: + return j + else: + i=i+s + s=s+2 + return -1 + +def h(k): + return k*2 + +T = [0,None,1,None,2,None,3,None,4] +print(ADDYHASHSEARCH(T,1)) +print(ADDYHASHSEARCH(T,3)) +print(ADDYHASHSEARCH(T,5))
\ No newline at end of file |