Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me with this C++ code, all of it if possible and be as specific

ID: 3601507 • Letter: C

Question


Can someone help me with this C++ code, all of it if possible and be as specific as you can, thanks in advance. Design a primary hash table data structure. (total 110 points) a. Each hash table has an array of node pointers and can point to a head of a linked list. Suppose b Override the default constructor with a constructor that has one default paramet called em c. Design the insert function that accept a value and inserts the value in the index of value%(size of d. Design a search function that accepts a value and checks to see if it is inside the table, if it is there e. Design a remove function to remove a value from the table. (10 pts) the node class is given to you. The data type of each node is int. (10 pts) capacity. What happens to your default constructor? Create some instances of the seq it using the new constructor in multiple ways. table). Try to be efficient. (10 pts) it return true. (5 pts) Overload + and - operators for hash table such that you may insert or remove a new integer to (10 pts) f. the hash table using this operator. (10 pts) 8. O verload >> operator for hash table such that it accepts a hash table and it inserts the element from the input into the table. (10 pts) h. Explain why the value semantics of your hash table class is not safe to use? Make the value i. Explain what is the running time of each function. (30 pts) whit ela you shul de

Explanation / Answer

public class HashTable {
  
   public static class Node {
       int data;
       Node next;
         
       Node(int data) {
       this.data = data;
       }
   }
  
   private int TABLE_SIZE;
   private Node[] table;
  
   // constructor
   //Note default constructor will not be valid anymore
   public HashTable(int capacity){
       TABLE_SIZE = capacity;
       table = new Node[TABLE_SIZE];
       for(int i=0;i<TABLE_SIZE;i++)
           table[i] = null;
   }
  
   public void insert(int data){
       int index = data%TABLE_SIZE;
       Node node = new Node(data);
       node.next = null;
       if(table[index]==null){
           table[index] = node;
       }else{
           Node root = table[index];
           Node previous = root;
           while(root!=null){
               previous = root;
               root = root.next;
           }
           previous.next = node;
       }
   }
  
   public boolean contains(int data){
       int index = data % TABLE_SIZE;
       Node root = table[index];
       while(root!=null){
           if(root.data == data)
               return true;
           root = root.next;
       }
       return false;
   }
}

// Above is the code for first four subpart of given question