Skip to content

Commit 4ba559d

Browse files
committed
Three Hundred - Sixteen Commit: Implement skeleton HashTableLinearProbe Class
1 parent b89ea97 commit 4ba559d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Section_11(Hash-Table)/(1)_hash-table-chaining.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
# Hash tables enable very efficient searching. In the best case, data can be retrieved from a hash table
1414
# in constant time, so you will find them wherever high performance searching is a requirement. Maintaining
1515
# (adding, updating and deleting) data in a hash table is also very efficient.
16+
17+
# Source: Hash Tables by isaaccomputerscience.org
18+
# URL: https://isaaccomputerscience.org/concepts/dsa_datastruct_hash_table?examBoard=all&stage=all
19+
1620
#
17-
# Implement Hashing using Chaining method
21+
# Hash Table (Dealing with collisions using Chaining Method)
1822
# Chains are represented using LinkedList
1923
#
20-
# Source: Hash Tables by isaaccomputerscience.org
21-
# URL: https://isaaccomputerscience.org/concepts/dsa_datastruct_hash_table?examBoard=all&stage=all
2224

2325
from linkedlist import LinkedList
2426
class HashChain:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Hash Table (Dealing with collisions using Linear Probing)
2+
# =========================================================
3+
# Linear probing is a scheme in computer programming for resolving collisions in hash tables, data structures for
4+
# maintaining a collection of key–value pairs and looking up the value associated with a given key.
5+
# It was invented in 1954 by Gene Amdahl, Elaine M. McGraw, and Arthur Samuel and first analyzed in 1963 by Donald Knuth.
6+
#
7+
# Along with quadratic probing and double hashing, linear probing is a form of open addressing. In these schemes,
8+
# each cell of a hash table stores a single key–value pair. When the hash function causes a collision by mapping
9+
# a new key to a cell of the hash table that is already occupied by another key, linear probing searches the table for
10+
# the closest following free location and inserts the new key there. Lookups are performed in the same way, by searching
11+
# the table sequentially starting at the position given by the hash function, until finding a cell with a matching key
12+
# or an empty cell.
13+
class HashTableLinearProbe:
14+
def __init__(self):
15+
self.hashtable_size = 10
16+
self.hashtable = [0] * self.hashtable_size

0 commit comments

Comments
 (0)