예제 #1
0
파일: t02.py 프로젝트: maxkdann/CP164
"""
-------------------------------------------------------
[program description]
-------------------------------------------------------
Author:  Max Dann
ID:      190274440
Email:   [email protected]
__updated__ = "2020-03-22"
-------------------------------------------------------
"""
from Hash_Set_array import Hash_Set
from Food_utilities import read_foods
fv = "foods.txt"
f = open(fv, "r", encoding="utf-8")
foods = read_foods(f)
h = Hash_Set(3)
l = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10]
for f in l:
    h.insert(f)
예제 #2
0
------------------------------------------------------------------------
Author: Nicolas Mills
ID:     180856100
Email:  [email protected]
__updated__ = 2019-03-18
------------------------------------------------------------------------
"""
from Hash_Set_array import Hash_Set
from Movie_utilities import read_movies

NUM_SLOTS = 7

print("\nTesting Hash_Set#debug()")

print("\n\nEmpty Hash_Set")
hs = Hash_Set(NUM_SLOTS)
hs.debug()

print('\n\nNon-empty Hash_Set')
for i in [1, 2, 3, 4]:
    hs.insert(i)
hs.debug()

print("\n\nHash_Set with movies")
fh = open('movies.txt', 'r')
movies = read_movies(fh)

hs = Hash_Set(NUM_SLOTS)
for movie in movies:
    hs.insert(movie)
예제 #3
0
"""
-------------------------------------------------------
[program description]
-------------------------------------------------------
Author:  Anshul Khatri
ID:      193313680
Email:   [email protected]
Section: CP164 Winter 2020
__updated__ = "2020-03-22"
-------------------------------------------------------
"""

from Hash_Set_array import Hash_Set
hash_set = Hash_Set(7)
hash_set.insert(12)
hash_set.insert(13)
hash_set.insert(14)
hash_set.insert(44)
hash_set.insert(15)

print("Hash set post inserting")
for i in hash_set:
    print(i)

hash_set.remove(33)
print()
print("Post removing")

for k in hash_set:
    print(k)
예제 #4
0
"""
------------------------------------------------------------------------
Lab 9, Task 4 - Hash_Set#rehash()
------------------------------------------------------------------------
Author: Nicolas Mills
ID:     180856100
Email:  [email protected]
__updated__ = 2019-03-18
------------------------------------------------------------------------
"""
from Hash_Set_array import Hash_Set
from Movie_utilities import read_movies
from random import randint

hs = Hash_Set(1)
fh = open('movies.txt', 'r')
movies = read_movies(fh)
"""
for i in range(100):
    for movie in movies:
        hs.insert(movie)
"""
for i in range(50):
    value = randint(0, 1000)
    hs.insert(value)
print("Slots: {}\tCount: {}\tAvg: {}\tLoad Factor: {}".format(
    hs._slots, hs._count, hs._count // hs._slots, hs._LOAD_FACTOR))
hs.debug()
예제 #5
0
"""
------------------------------------------------------------------------
Assignment 9, Task 1 - Hash_Set_Array, insert_words, comparison_total
------------------------------------------------------------------------
Author: Nicolas Mills
ID:     180856100
Email:  [email protected]
__updated__ = 2019-03-25
------------------------------------------------------------------------
"""
from functions import insert_words, comparison_total
from Hash_Set_array import Hash_Set

print("Using array-based list Hash_Set")

fv = open('miserables.txt', 'r')
hs = Hash_Set(20)

insert_words(fv, hs)
total, max_word = comparison_total(hs)

print("\nTotal Comparisons: {:,}".format(total))
print("Word with max comparisons: {}: {:,}".format(max_word.word,
                                                   max_word.comparisons))
예제 #6
0
"""
-------------------------------------------------------
t03
-------------------------------------------------------
Author:  Anshul Khatri
ID:      193313680
Email:   [email protected]
Section: CP164 Winter 2020
__updated__ = "2020-04-03"
-------------------------------------------------------
"""
from functions import insert_words, comparison_total
from Hash_Set_array import Hash_Set

fv = open('miserables.txt', 'r')

hash_1 = Hash_Set(20)

insert_words(fv, hash_1)

total, max_word = comparison_total(hash_1)

print("Using  BST Hash_Set")

print("Total Comparisons: {} ".format(total))

print("Word with maximum comparisons '{}': {}".format(max_word.word,
                                                      max_word.comparisons))
예제 #7
0
"""
-------------------------------------------------------
[program description]
-------------------------------------------------------
Author:  Anshul Khatri
ID:      193313680
Email:   [email protected]
Section: CP164 Winter 2020
__updated__ = "2020-03-22"
-------------------------------------------------------
"""

from Hash_Set_array import Hash_Set

hash_set = Hash_Set(7)

hash_set.insert(111)
hash_set.insert(222)
hash_set.insert(332)
hash_set.insert(442)
hash_set.insert(552)

hash_set.debug()