aboutsummaryrefslogtreecommitdiffstats
path: root/csci4041
diff options
context:
space:
mode:
Diffstat (limited to 'csci4041')
-rw-r--r--csci4041/hw2prob2.py18
-rw-r--r--csci4041/hw2prob3.py34
-rw-r--r--csci4041/hw3prob2.py21
-rw-r--r--csci4041/mergeSort_py.py30
4 files changed, 0 insertions, 103 deletions
diff --git a/csci4041/hw2prob2.py b/csci4041/hw2prob2.py
deleted file mode 100644
index 39e533a..0000000
--- a/csci4041/hw2prob2.py
+++ /dev/null
@@ -1,18 +0,0 @@
-
-# Watch the value of K!!!
-# - Jeremiah
-def making_sets(n, k, e, s):
- if k == 0:
- print(s)
- else:
- for e_i in range(e, n + 1):
- s = set.union(s, {e_i})
- making_sets(n, k - 1, e_i + 1, s)
- s = set.difference(s, {e_i})
-
-def make_sets(n, k):
- making_sets(n, k, 1, set())
-
-make_sets(4,3)
-print()
-make_sets(6,1)
diff --git a/csci4041/hw2prob3.py b/csci4041/hw2prob3.py
deleted file mode 100644
index cc53704..0000000
--- a/csci4041/hw2prob3.py
+++ /dev/null
@@ -1,34 +0,0 @@
-def CHILD(i,j):
- return 2*i + (j+1)
-
-def IS_IN_MIN_HEAP(A,e):
- return FIND_ELEMENT(A,0,e)
-def FIND_ELEMENT(A,i,e):
- if A[i] is e:
- return True
- else:
- bool = False
- lChild = CHILD(i, 0)
- rChild = CHILD(i, 1)
- if lChild < len(A) and A[lChild] <= e:
- bool = FIND_ELEMENT(A, lChild, e)
- if bool is not True and rChild < len(A) and A[rChild] <= e:
- bool = FIND_ELEMENT(A, rChild, e)
- return bool
-
-#TEST MIN-HEAP
-#Feel free to redefine as much as you want
-l = [0, 2, 3, 5, 6, 8, 9]
-
-#TESTS
-print(IS_IN_MIN_HEAP(l, 0))
-print(IS_IN_MIN_HEAP(l, 1))
-print(IS_IN_MIN_HEAP(l, 2))
-print(IS_IN_MIN_HEAP(l, 3))
-print(IS_IN_MIN_HEAP(l, 4))
-print(IS_IN_MIN_HEAP(l, 5))
-print(IS_IN_MIN_HEAP(l, 6))
-print(IS_IN_MIN_HEAP(l, 7))
-print(IS_IN_MIN_HEAP(l, 8))
-print(IS_IN_MIN_HEAP(l, 9))
-print(IS_IN_MIN_HEAP(l, 200)) \ No newline at end of file
diff --git a/csci4041/hw3prob2.py b/csci4041/hw3prob2.py
deleted file mode 100644
index 33f36f6..0000000
--- a/csci4041/hw3prob2.py
+++ /dev/null
@@ -1,21 +0,0 @@
-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
diff --git a/csci4041/mergeSort_py.py b/csci4041/mergeSort_py.py
deleted file mode 100644
index bc9ae7d..0000000
--- a/csci4041/mergeSort_py.py
+++ /dev/null
@@ -1,30 +0,0 @@
-def head(Q):
- return Q[0]
-def tail(Q):
- return Q[1:]
-def mergesort(U):
- if U == [] or tail(U) == []:
- return U
- else:
- L = []
- R = []
- while U != [] and tail(U) != []:
- L = L+[head(U)]
- U = tail(U)
- R = R+[head(U)]
- U = tail(U)
- L = L + U
- L = mergesort(L)
- R = mergesort(R)
- s = []
- while L != [] and R != []:
- if head(L) <= head(R):
- s = s + [head(L)]
- L = tail(L)
- else:
- s = s + [head(R)]
- R = tail(R)
- s = s + L + R
- return s
-
-print(mergesort([9,3,7,5,6,4,8,2])) \ No newline at end of file