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

  Explain how risc-pipelining evolved over past years

Explain how concepts such as RISC, pipelining, cache memory, and virtual memory have evolved over the past twenty-five years to improve system performance.

  Cpu-best performance improvement for least amount of money

Suppose the daytime processing load consists of 60% CPU activityand 40% disk activity. Your customers are complaining that thesystem is slow. Which would you choose to yield the best performance improvement for the least amount of money?

  Explaining reasonable values for items in risk register

Suggest reasonable values for the items in the risk register for this asset and threat, and provide justifications for your choices.

  Compare iso-iec outline with nist documents

Compare the ISO/IEC 27001 outline with the NIST documents outlined in 'Management of Information Security' (by Michael E. Whitman, Herbert J. Mattord).

  Access and its limitations in distributed business model

describe the difference of the two terms and how they work together. Your post should include the following details: A description of Access and its limitations in a distributed business model.

  Explain effects of compaction on normal processing

What about if you upgrade to memory that can be read or written to in 1nsec? Comment briefly on the effects of compaction on normal processing.

  Following class definition

Given the following class definition, describe the type of variables used by the arguments and return values of the following member functions (values, pointers, or references):

  Advantages and disadvantages of virtual offices

Write down the advantages and disadvantages of virtual offices, including telecommuting? Reply this question twice-once from the point of view of employee, once from the point of view of manager.

  Describing how prolog executes command

Describe how Prolog executes command (query) and goal matching process.

  Calculate a checksum as ones-complement sum

Calculate a checksum as ones-complement sum of following 8-bit words #1 through #4, and then ones-complement that sum. Illustrate the 8-bit result.

  Designing a 4-to-16 decoder using not gates

Draw 4-to-16 decoder by using components. You must not use any extra components.

  Message exchange patterns in soap

Let two main types of message exchange patterns in SOAP (and operation types in WSDL): (1) request-response and (2) one-way.

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