After modify the following code please split which part will be main.java file and which part will be hashtableclass.java file? Because I will use main.java IDE.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

After modify the following code please split which part will be main.java file and which part will be hashtableclass.java file? Because I will use main.java IDE.

Modify the given programs by adding two methods in HashTableClass: Show Full code with output. Please Don't copy previous solution.

  1. Find and return the item with the maximum key;
  2. Find and return average of the keys in the hash table.

 

import java.util.*;
public class hashTableClass {
    public int tableSize; 
    Node[] T;
    public hashTableClass()
    { 
        System.out.println("Give the hash table size");
        tableSize = Integer.parseInt(new Scanner(System.in).nextLine());
        T = new Node[tableSize];
        for (int i = 0; i < tableSize; i++)
            T[i] = null;
    }

    public int hashFunction(int Key)
    { 
        return Key % tableSize; 
    }
    public Node Search(int Key)
    {
      int h = hashFunction(Key);
      Node current = T[h];
      while (current != null && current.item != Key)
         current = current.link;
      return current;
    }
    public void Insert(int newItem)
    {
        int h = hashFunction(newItem);
        Node current = T[h];
        Node newNode = new Node(newItem);
        newNode.link = T[h];
        T[h] = newNode;
    }
    public void Delete(int Key)
    { 
        int h = hashFunction(Key);
        if (T[h] == null) // The list is empty!
            System.out.println("There is no such item!");
        else
        {  
            if (T[h].item == Key) // The only node in the list is to be deleted.
                T[h] = T[h].link;
            else // The list has more than one node.
            { 
                Node p = searchPrevious(Key);
                if (p.link == null)
                     System.out.println("There is no such item!");
                else 
                    p.link = p.link.link;
             } 
        }
    }
    public Node searchPrevious(int key)
    {
        int h = hashFunction(key);
        if (T[h] == null)
        {
            return T[h];
        }
        else
        {
            Node current = T[h];
            while (!(current.link == null) && (current.link.item != key))
            {
                current = current.link;
            }
            return current;
        }
    }
    public void PrintHashTable()
    {
        for (int i = 0; i <= tableSize - 1; i++)
        { 
            if (T[i] == null)
                System.out.println("T(" + i + "): " + "no item" + "\n");
             else
             { 
                 Node current = T[i];
                 System.out.print("T(" + i + "): " + current.item + ", ");
                 while (!(current.link == null))
                 { 
                     current = current.link;
                     System.out.print(+current.item + ", ");
                 }
             System.out.println("\n");}
               }
        }   

    
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY