Skip to content

Commit 5d003f9

Browse files
Chaining Implementation In Hash Tables
1 parent 9899c20 commit 5d003f9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Implementation of Chaining in Hash Tables using lists in python
2+
class MyHash:
3+
def __init__(self, b):
4+
self.bucket = b
5+
self.table = [[] for x in range(b)]
6+
7+
def insert(self, x):
8+
i = x % self.bucket
9+
self.table[i].append(x)
10+
11+
def remove(self, x):
12+
i = x % self.bucket
13+
self.table[i].remove(x)
14+
15+
def search(self, x):
16+
i = x % self.bucket
17+
return x in self.table[i]

0 commit comments

Comments
 (0)