computer science c programming 1

For this assignment, write a class named HashTable that implements a hash table using linear probing to resolve collisions.

Submit your solution in it’s own header file named HashTable.h.

Your solution should include the following methods in it’s public interface:

  • insert() – accepts a string as it’s only argument, which is added to the hash table, setting the element’s mark where it is stored to 2.
  • remove() – accepts a string as it’s only argument, and removes the string from the hash table (if found) by setting it’s mark to 1.
  • isFull() – returns true if the hash table is full, false otherwise.
  • isEmpty() – returns true if the hash table is empty, false otherwise.
  • find() – accepts a string as it’s only argument. Returns true if it is found in the hash table, false otherwise.
  • clear() – empties the hash table by setting each elements mark to 0.
  • print() – displays the contents of the hash table to the screen. That is, only the elements that are being used (marked with 2)
  • constructor – accepts an integer as it’s only argument, creating a hash table that can store that many values (a dynamically allocated array of Elements).
  • destructor – frees all memory used.

Other than the print() method, none of these methods should interact with the user in any way.

Here’s a list of private attributes:

  • Element – a nested struct containing the following fields:
    • key – Stores the string passed to the object through the insert method.
    • mark – an variable set to 2 if the element is being used, 1 if it was used but then was deleted, and 0 if it was never used.
  • table – an Element pointer that holds the memory address of a dynamically allocated array of Elements.
  • size – stores the size of the Element array.
  • hash – The hash function. It accepts a String as it’s only argument and returns an index into the hash table. Design your hash function any way you wish. I gave a couple suggestions in class. My solution will use the sum of ascii values approach.
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.