Dsa 2 Prathmesh
Dsa 2 Prathmesh
TITLE: Implement all the functions of a dictionary (ADT) using hashing and handle collisions
using chaining with / without replacement. Data: Set of (key, value) pairs, Keys are mapped to
values, Keys must be comparable, Keys must be unique Standard Operations: Insert(key,
value), Find(key), Delete(key)
PROGRAM:
def display(self):
print("\n\t\tKey\t\tName") for i in range(10):
print("\n\th[{}]\t{}\t\t{}".format( i, self.h[i]['key'], self.h[i]
['name'])) def find(self, k): for i in range(10): if
self.h[i]['key']
== k: print("\n\t{} is Found at {} Location With Name
{}".format( self.h[i]['key'], i, self.h[i]['name'])) return
i
print("\n\tKey Not Found")
return -1
def delete(self,
k):
index = self.find(k) if index != -1:
self.h[index]['key'] = -1 self.h[index]['name']
= "NULL"
print("\n\tKey is Deleted")
Output:-