diff --git a/DS.py b/DS.py index 8024917..00c50b1 100644 --- a/DS.py +++ b/DS.py @@ -5,5 +5,5 @@ class DS: MIN_HEAP = 3 MAX_HEAP = 4 HASHTABLE = 5 - NUM_STRUCTURES = 5 + NUM_STRUCTURES = 7 diff --git a/DS.pyc b/DS.pyc deleted file mode 100644 index 2193f72..0000000 Binary files a/DS.pyc and /dev/null differ diff --git a/arr.pyc b/arr.pyc deleted file mode 100644 index 9c696a4..0000000 Binary files a/arr.pyc and /dev/null differ diff --git a/bst.pyc b/bst.pyc deleted file mode 100644 index 6444336..0000000 Binary files a/bst.pyc and /dev/null differ diff --git a/btree.pyc b/btree.pyc deleted file mode 100644 index 62a6ec2..0000000 Binary files a/btree.pyc and /dev/null differ diff --git a/main.py b/main.py index d50ed16..4dad474 100644 --- a/main.py +++ b/main.py @@ -17,16 +17,21 @@ class SD: data structure. """ def __init__(self, isTesting, which = None): - + print(which) if which == DS.ARRAY: + print "Array" self.struct = Arr() elif which == DS.SORTED_ARRAY: + print "S Array" self.struct = SArr() elif which == DS.MAX_HEAP: + print "M Heap" self.struct = MaxHeap() elif which == DS.MIN_HEAP: + print "min heap" self.struct = MinHeap() elif which == DS.BINARY_SEARCH_TREE: + print "bst" self.struct = Balanced_BST() else: print "Default to Array" @@ -39,39 +44,67 @@ def __init__(self, isTesting, which = None): self.get_min_ctr = 0 self.extract_ctr = 0 self.extract_min_ctr = 0 + self.num_ops = 0 + self.isTesting = isTesting self.len = 0 def contains(self, key): + self.contains_ctr += 1 + self.num_ops += 1 return self.struct.contains(key) def add(self, key): self.struct.add(key) self.len += 1 + self.add_ctr += 1 + self.num_ops += 1 def remove(self, key): self.struct.remove(key) self.len -= 1 + self.num_ops += 1 + self.remove_ctr += 1 def get(self, index): + self.get_ctr += 1 + self.num_ops += 1 return self.struct.get(index) def get_min(self): + self.get_min_ctr += 1 + self.num_ops += 1 return self.get(self, 0) def get_max(self): + self.get_max_ctr += 1 + self.num_ops += 1 return self.get(self, len - 1) def extract(self, index): toReturn = get(self, index) remove(self, index) + self.extract_ctr += 1 + self.num_ops += 1 return toReturn def extract_min(self): extract(self, 0) + self.extract_min_ctr += 1 + self.num_ops += 1 def extract_max(self): extract(self, self.len - 1) + self.extract_max_ctr += 1 + self.num_ops += 1 def size(self): return self.len + + def reeval(self): + if self.isTesting: + return + else: + print "NEED TO IMPLEMENT" + + diff --git a/main.pyc b/main.pyc deleted file mode 100644 index d50ef2e..0000000 Binary files a/main.pyc and /dev/null differ diff --git a/maxheap.pyc b/maxheap.pyc deleted file mode 100644 index e373eb0..0000000 Binary files a/maxheap.pyc and /dev/null differ diff --git a/minheap.pyc b/minheap.pyc deleted file mode 100644 index aa6185c..0000000 Binary files a/minheap.pyc and /dev/null differ diff --git a/sarr.pyc b/sarr.pyc deleted file mode 100644 index e9d3430..0000000 Binary files a/sarr.pyc and /dev/null differ diff --git a/test.py b/test.py index 88dd681..4c8831f 100644 --- a/test.py +++ b/test.py @@ -21,7 +21,7 @@ def test(): print(str(s_data.get(0)) + " should be 0") -s_data = SD(True) +s_data = SD() # -------------- # Array Test diff --git a/test_compile_6.py b/test_compile_6.py new file mode 100644 index 0000000..4ca7ac5 --- /dev/null +++ b/test_compile_6.py @@ -0,0 +1,25 @@ +# Test File + +from main import * +import itertools +from random import * +from sarr import * +from minheap import * +from maxheap import * +from bst import * + +def test(): + s_data.len = 0 + + for x in choice([x for x in itertools.permutations(range(10))]): + s_data.add(x) + + print(str(s_data.contains(3)) + " should be true") + + s_data.remove(3) + print(str(s_data.contains(3)) + " should be false") + + print(str(s_data.get(0)) + " should be 0") + +s_data = SD(6, True) +test()