Write a program that reads two positive integers D and i (in this order) from its input and adds the rest of the integers (all non-negative) in the input to a hash table of size D. Finally the program should output the content of the table. Use closed hashing with linear probing where the parameter is i and h(x)=x. The content of the table should be printed in the following format: -1 7 8 ..... where the output contains exactly D lines and an empty slot is printed as -1.
"please turn this python code to c++"
class hashTable:
def _init_(self):
self.size = int(input('Enter the size of hash table:'))
#initializwe the table with 0
self.table = list(None for i in range(self.size))
self.elementCount = 0
# function to get the position for element
def hashFunction(self,key):
return key%self.size
#function to check if hash table is full or not
def isFull(self):
if self.elementCount == self.size:
return True
else:
return False
#function to insert data into hash table
def insert(self,data):
#check if table is full
if self.isFull():
print("hash table is full")
return False
position = self.hashFunction(data)
#checking if positiohn is empty
if self.table[position] == None:
self.table[position] = data
self.elementCount+=1
#if collision occur linear probing is done
else:
while self.table[position] != None:
position+=1
if position >= self.size:
position = 0
self.table[position] = data
#function to display the hash table
def display(self):
for i in range( self.size):
print(self.table[i]+"\n")
ht = hashTable()
i = int(input("Enter interger to be inserted into hash table"))
ht.insert(i)
ht.display()
![Write a program that reads two positive integers D and i (in this order) from its input and adds the rest of
the integers (all non-negative) in the input to a hash table of size D. Finally the program should output the
content of the table.
Use closed hashing with linear probing where the parameter is i and h(x)=x.
The content of the table should be printed in the following format:
-1
7
8
.....
where the output contains exactly D lines and an empty slot is printed as -1.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe1970764-eba4-433f-a458-68ccd941ae3c%2F822c1e4f-00e2-4ef1-8dcb-523d82af67d6%2F88is37h_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)