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

  Literature for information on position of cko

Investigate literature for information on position of CKO and find out an approximate percentage of firms with knowledge management initiatives which have CKOs.

  Design static method below to find and return complex number

Given a "Complex" class with all the standard methods for complex numbers, design the static method below to find and return the smallest complex number.

  Create two-page written analysis for problem statement

Create a two-page written analysis based on the following specification: Problem statement, Possible outcomes if no action taken (this one is mine and the only thing i have to do) Alternative actions.

  It solution to utilize as a strategic weapon

Why is it so imperative for an organization, regardless of size, to explain a Business Model, and then look for which IT solution to utilize as a strategic weapon?

  Calculate fourier transform of function

Given a function f(x) as follows: f(0) = 2, f(1) = 3, f(2) = 5, f(3) = 4. Calculate the Fourier Transform of f(x), i.e: F(0), F(1), F(2) and F(3)!

  Explain advantages of having componentized system

Explain some of the advantages of having componentized system. For instance, What occurs if the microwave breaks?

  Describe tttc management significance of observing user

Using at least two articles for support, describe to TTTC management the significance of observing user reaction, suggestions, and innovations in prototyoping process.

  Write guide for the organization

Write a 2-3 page report recommending style manual and/or technical/legal writing guide for the organization to use and describe the reasons for your recommendations.

  Protect proprietary interest by addressing ethical issues

Advise whether you agree or disagree with CEO, specifically addressing ethical issues involved. Suppose you make a decision to hire a hacker, how would you protect your proprietary interests?

  Drawing class diagram to show instructor serves department

One instructor also serves a department chair. Draw a detailed class diagram to represent the above information.

  Write down sructured english for clyde-s narrative

On a trip lasting more than one day, we permit hotel, taxi, and airfare also meal allowances. Same times apply for meal expenses. Write down sructured English for Clyde's narrative of the reimbursement policies.

  Calculate performance of cache and the average cpi

Assume the instruction cache miss rate is 0.5% and the data cache miss rate is 1%. Calculate the performance of the cache (CPU execution time) and the average CPI.

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