This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author : Agung Pambudi | |
#email : [email protected] | |
#version : 0.1 | |
#============================================================================== | |
# _ _ _ | |
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____ | |
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | | | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_| | |
# |___| |___|_| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author : Agung Pambudi | |
#email : [email protected] | |
#version : 0.1 | |
#============================================================================== | |
# _ _ _ | |
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____ | |
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | | | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_| | |
# |___| |___|_| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author : Agung Pambudi | |
#email : [email protected] | |
#version : 0.1 | |
#============================================================================== | |
# _ _ _ | |
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____ | |
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | | | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_| | |
# |___| |___|_| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author : Agung Pambudi | |
#email : [email protected] | |
#version : 0.1 | |
#============================================================================== | |
# _ _ _ | |
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____ | |
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | | | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_| | |
# |___| |___|_| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author : Agung Pambudi | |
#email : [email protected] | |
#version : 0.1 | |
#============================================================================== | |
# _ _ _ | |
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____ | |
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | | | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_| | |
# |___| |___|_| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HashTable: | |
def __init__(self): | |
self.size = 11 | |
self.slots = [None] * self.size | |
self.data = [None] * self.size | |
def put(self,key,data): | |
hashvalue = self.hashfunction(key,len(self.slots)) | |
if self.slots[hashvalue] == None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in state list: 1 means occupied, 0 means empty and -1 means deleted | |
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.next = None | |
class QuadraticProbing: | |
def __init__(self, size=100, load_factor=0.75): | |
self.items_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class hashtable_chain(object): | |
'''Chain collision implemented hash table''' | |
def __init__(self, hash_array_size=11): | |
self.size = hash_array_size | |
self.key_values_pairs = [[]]*hash_array_size | |
def _hash_function(self, x): | |
''' Private hash function. | |
Convert x into a string. | |
For each letter in string, position * ord(letter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyHashTable: | |
def __init__(self): | |
self.size = 11 | |
self.positions = [None] * self.size | |
self.values = [None] * self.size | |
def put(self,key,value): | |
hashvalue = self.hashfn(key,len(self.positions)) | |
if self.positions[hashvalue] == None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in state list: 1 means occupied, 0 means empty and -1 means deleted | |
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.next = None | |
class DoubleHashing: | |
def __init__(self, size=100, load_factor=0.75): | |
self.items_count = 0 |