This code uses separate chaining

Assignment Help Basic Computer Science
Reference no: EM13163630

This code uses separate chaining ...implement it using double hashing. Implement a separate-chaining table in which each integer x is hashed twice using two different hash functions h1(x) and h2(x). This will perhaps produce two different locations for x. Place x in the location that has the smaller chain.

public static void interactiveMode(Scanner input) {
   int menuChoice = 0;
   do {
   System.out.println("\nInteractive Mode:");
   System.out.println("1. Enter size of table");
   System.out.println("2. Enter an integer");
   System.out.println("3. Find integer");
   System.out.println("4. Exit to Main Menu.");
   System.out.print("Please enter a selection: ");

   menuChoice = input.nextInt();
   input.nextLine();
   System.out.println();
   switch (menuChoice) {
   case 1:
   System.out.print("Enter size of table: ");
   int n = input.nextInt();
   size=n;
   a = new ArrayList[size];
   for (int i = 0; i < size; i++) {
   a[i] = new ArrayList<Integer>();
   }
   print();
   break;
   case 2:
       System.out.println("Enter an integer for the table");
      
       int m = input.nextInt();
       int index = m % size;
       a[index].add(m);
       print();
       break;
   case 3:
   System.out.print("Enter an integer to find: ");
   int search = input.nextInt();
   if (find(search)) {
   System.out.println("Integer " + search + " is in the table.");
   }
   else {
   System.out.println("Integer " + search + " is not in the table.");
   }
   break;
   default:
   if (menuChoice != 4) {
   System.out.println("Enter correct number.");
   }
   break;
   }
   } while (menuChoice != 4);
   }

Reference no: EM13163630

Questions Cloud

Trigger named products_insert : Create a trigger named Products_INSERT that inserts the current date for the DateAdded column of the Products table if the value for that column is null. Test this trigger with an appropriate INSERT statement.
Write a java binary search tree program : write a JAVA binary search tree program
Create an array of integers at random : create an array of integers at random with a range of 0 through 1000 in Java... any hints?
Trigger named products_update : Create a trigger named Products_UPDATE. This trigger should insert the old data about the product into the ProductsAudit table after the row is updated. Then, test this trigger with an appropriate UPDATE statement.
This code uses separate chaining : This code uses separate chaining ...implement it using double hashing. Implement a separate-chaining table in which each integer x is hashed twice using two different hash functions h1(x) and h2(x). This will perhaps produce two different location..
Recall that a computer virus is malware : Recall that a computer virus is malware that relies on someone or something (other than itself) to propagate from one system to another. Write a computer virus that can be written to other empty text documents by running the batch program.
Atmega128 is being used to monitor humidity inside test cham : Atmega128 is being used to monitor humidity inside test chamber 03. The device uses two sensors to have some fault tolerance. They are connected to ADC channels 0 and 1. The program uses the average and maximum error of the two values.
The time delay of a long-distance : The time delay of a long-distance call can be determined by multiplying a small fixed constant by the number of communication links on the telephone network between the caller and callee
Write a function to compute the magnitude f : write a function to compute the magnitude F and direction angle of a two-dimensional force F by using two components of the force fx,fy as its parameters,returning F and using the reference to pass theta value .

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Descriptions of data formats and to interpret raw data

The aim of this project is to exercise and test your ability to read and understand descriptions of data formats and to interpret raw data according to a particular format.  In this exercise you will produce and read the dump of a ZIP file.

  Evaluating a new hands-free input device

You have been tasked with evaluating a new hands-free input device, the "chair mouse", which the user manipulates by shifting his/her weight in a specially instrumented chair.

  Register mapping and then any possible

First do the register mapping and then any possible instruction reordering. How many machine registers are used? Has there been any pipeline improvement?

  Task manager to recognize and troubleshoot problems

Which system resources are probable to be at root of problem? How can you use system tools, like the Task Manager, to help recognize and troubleshoot these problems?

  What are techniques to use in planning presentation

You prepared and distributed a system requirements document, and you anticipate some intense questioning at the meeting. When planning your presentation, what are some techniques you will use?

  Give upper bound on number of training

Give an upper bound on the number of training examples sufficient to assure with 90% confidence that the learned perceptron will have true error of at most 5%. Does this bound seem realistic?

  Write difference between logical and physical modeling

What is the difference between logical and physical modeling? Give three reasons why logical models are superior for structuring business requirements.

  Show with diagrams how the median filters work

Explain why in some image processing scenarios, filters are used instead of point operations on pixel values Show with diagrams how the Median Filters work

  Relationship of human service organizations and populations

How do the unique relationship between human service organizations and the populations they serve impact ethical decisions?

  Function that finds the smallest element

Function that finds the smallest element in an array of double values using the following header: double min(double array[], int size)

  Activity diagram of each step of ordering pizza

Draw an activity diagram representing each step of the process; from the moment you pick up the phone to the point where you are eating the pizza.

  Analyze faster processor chip result increase in performance

Analyze the following statement: "Using the faster processor chip results in corresponding increase in performance of a computer even if main memory speed remains same."

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd