From 9deabe475c28a7547522be62bc263143db9bf721 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sat, 9 May 2020 14:09:47 -0500 Subject: rearrange homework folders --- OLD/csci4041/hw3prob2.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 OLD/csci4041/hw3prob2.py (limited to 'OLD/csci4041/hw3prob2.py') diff --git a/OLD/csci4041/hw3prob2.py b/OLD/csci4041/hw3prob2.py new file mode 100644 index 0000000..33f36f6 --- /dev/null +++ b/OLD/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 -- cgit v1.2.3