Skip to content

Instantly share code, notes, and snippets.

View AgungPambudi's full-sized avatar
😃
Learning by doing

Agung Pambudi AgungPambudi

😃
Learning by doing
View GitHub Profile
#author : Agung Pambudi
#email : mail@agungpambudi.com
#version : 0.1
#==============================================================================
# _ _ _
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_|
# |___| |___|_|
#author : Agung Pambudi
#email : mail@agungpambudi.com
#version : 0.1
#==============================================================================
# _ _ _
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_|
# |___| |___|_|
#author : Agung Pambudi
#email : mail@agungpambudi.com
#version : 0.1
#==============================================================================
# _ _ _
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_|
# |___| |___|_|
#author : Agung Pambudi
#email : mail@agungpambudi.com
#version : 0.1
#==============================================================================
# _ _ _
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_|
# |___| |___|_|
#author : Agung Pambudi
#email : mail@agungpambudi.com
#version : 0.1
#==============================================================================
# _ _ _
# ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____
#| .'| . | | | | . | . | .'| | . | | | . | |_| _| . | |
#|__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_|
# |___| |___|_|
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:
@AgungPambudi
AgungPambudi / quadraticProbing.py
Created March 10, 2021 09:59 — forked from cs-fedy/quadraticProbing.py
hash table quadratic probing implementation Python
# 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
@AgungPambudi
AgungPambudi / hash-table.py
Created March 10, 2021 09:59 — forked from georgeteo/hash-table.py
Hash Tables
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)
@AgungPambudi
AgungPambudi / hashtable.py
Created March 10, 2021 09:59 — forked from sachinnair90/hashtable.py
Simple Hash table implementation in Python
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:
@AgungPambudi
AgungPambudi / doubleHashing.py
Created March 10, 2021 09:59 — forked from cs-fedy/doubleHashing.py
hash table double hashing implementation Python
# 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