Question: In c + + , please complete the following functions implementing a Hash Table for Quadratic Probing closed hashing table in a Snake Game. Your

In c++,please complete the following functions implementing a Hash Table for Quadratic Probing closed hashing table in a Snake Game. Your hash table will be used to keep a small collection of selected treasures from the ItemBin as the bingo conditionfor each player instance, and upon collecting each treasure, the matched treasure will be lazy-deleted from the hash table. As soon as one of the player instances reaches a hash table load factor lambda =0,the player completes the bingo condition and wins the game. Refer to attached image for function requirements. Below is the objPosDoubleHashing class (that needs filling based on the attached image requirements) and header files.
#include "objPosDoubleHashing.h"
//#include "MacUILib.h"
#include
using namespace std;
objPosDoubleHashing::objPosDoubleHashing()
{
//Instantiate the objPos Hash Table of the default size TABLE_SIZE defined in the objPosHashTable abstract class
//Should also initialize tableSize field with the default size TABLE_SIZE
}
objPosDoubleHashing::objPosDoubleHashing(int size)
{
//Instantiate the objPos Hash Table of the specified size
//Should also initialize tableSize field with specified size
}
objPosDoubleHashing::~objPosDoubleHashing()
{
//delete the Hash Table
}
int objPosDoubleHashing::calculateHashing(int prefix, int number)const //hashing function
{
//Implementing the primary hashing function
//Add all the decimal integer digits of the Prefix ASCII char and the Number together
//For example, given objPos.prefix ='A'(65)and objPos.number =98,then...
// h(x)=sum of all decimal digits of prefix and number =6+5+9+8=28
//return the sum as the hashing key.
}
int objPosDoubleHashing::calculateSecondaryHashing(int input)const
{
//Implementing the secondary hashing function
//1.Sum up all digits of input
//2.return 5-(sum mod 5)
//e.g. input =18
// sum =1+8=9
// return value =5-(9%5)=5-4=1
}
bool objPosDoubleHashing::insert(const objPos &thisPos)
{
//Algorithm similar to the one discussed in class
//1.Calculate the initial hashing key using calculateHashing()private helper function (i.e.the h1(x))
//2.Check symbol field to see whether the indexed slot is empty
// If yes, insert data, set symbol to 'v',then return true (indicating successful insertion)
// Otherwise, proceed to collision resolution
//3.Collision resolution strategy -Double Probing
// h(x)=(h1(x)+i*h2(x))mod tableSize (i is the probing count)
// where h2(x)=5-(sum of all digits of h1(x))mod 5)
//4.For every newly calculated key using quadratic probing, check for empty slot for insertion
// If empty slot is found, insert data, set symbol to 'v',then return true (indicating successful insertion)
// If element is already inserted, return false (indicating failed insertion)
// If probing count exceeds MAX_PROBING_COUNT defined in objPosHash.h,return false
//(too many probing attempts, may lead to integer overflow)
}
#ifndef OBJPOS_DOUBLE_HASHING_H
#define OBJPOS_DOUBLE_HASHING_H
#include "objPosHash.h"
#include "objPos.h"
class objPos;
class objPosDoubleHashing : public objPosHashTable
{
private:
objPos*myHashTable;
int calculateHashing(int prefix, int number)const; //hashing function
int calculateSecondaryHashing(int input)const; //secondary hashing function
//signature subject to change
public:
objPosDoubleHashing();
objPosDoubleHashing(int);
virtual ~objPosDoubleHashing();
bool insert(const objPos &thisPos);
bool remove(const objPos &thisPos); //lazy delete
bool isInTable(const objPos &thisPos)const;
double getLambda()const;
void printMe()const;
};
#endif
In c + + , please complete the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!