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
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
"""
file: hashtable.py
language: python3
author: sps@cs.rit.edu Sean Strout
author: jeh@cs.rit.edu James Heliotis
author: anh@cs.rit.edu Arthur Nunes-Harwitt
author: hotchkiss@rit.edu Collin Hotchkiss
description: open addressing Hash Table for CS 242 Lecture
"""
import copy
@AgungPambudi
AgungPambudi / hash_table.py
Created March 10, 2021 09:58 — forked from edwintcloud/hash_table.py
Hash Table Implementation in Python
from linked_list import LinkedList
class HashTable(object):
def __init__(self, items = None):
"""Initialize this HashTable and set items if specified"""
self.slots = [LinkedList() for i in range(8)] # start with 8 slots
self.size = 0