Professional Documents
Culture Documents
1
else:
print("Hash Table is Full..!!")
return
def main():
t1=telephonedirectory()
t1.insertRecord(56)
m=int(input("enter total no of records to the insert= "))
for i in range(m):
t1.insertRecord(int(input("Enter Value= ")))
main()
Output:
Enter size for Hash Table= 4
[0, 0, 0, 0]
[56, 0, 0, 0]
enter total no of records to the insert= 5
Enter Value= 1
[56, 1, 0, 0]
Enter Value= 2
[56, 1, 2, 0]
Enter Value= 3
[56, 1, 2, 3]
Enter Value= 4
Hash Table is Full..!!
Enter Value= 4
Hash Table is Full..!!
2
Program Usinng separate_chaining_linked_list :-
class Node:
def init (self, data):
self.data = data
self.next = None
class LinkedList:
def init (self):
self.head = list(None for i in range(10))
print(self.head)
def printLL(self):
for i in range(10):
current_node = self.head[i]
if(self.head[i] == None):
print('\n',i, ' index list is empty=')
else:
print ('\n',i, 'index list is ',end=' ')
while(current_node):
print(current_node.data, end=' ')
current_node = current_node.next
3
self.head[index] = new_node
def search(self):
teleph_no = int(input('enter telephone no to be search= '))
index = teleph_no % 10
temp = self.head[index]
while(temp):
if (temp.data == teleph_no):
print ('telephone no found at index ', index)
return
else :
temp = temp.next
print ('telephone not found')
def main():
print('Hello..!! Welcome in DSA program--!!')
L1 = LinkedList()
for i in range(5):
L1.insertAtBegin(int(input('enter telephone number= ')))
L1.printLL()
L1.search()
main()
Output:
Hello..!! Welcome in DSA program--!!
[None, None, None, None, None, None, None, None, None, None]
enter telephone number= 12345
4
2 index list is empty=
5
7 index list is empty=