Given a hash function hkey prepare a java simulation

Assignment Help JAVA Programming
Reference no: EM13351132

Given a hash function h(key), prepare a java simulation program to determine each of the subsequent quantities after 0.8*tablesize random keys have been generated. The keys should be random integers. 

1. The percentage of integers between 0 and tablesize-1 that do not equal h(key) for some generated key. 

2. The percentage of integers between 0 and tablesize-1 that equal h(key) for more than one generated key. 

3. The maximum number of keys that hash into a single value between 0 and tablesize-1.  Run the program to test the uniformity of each of the following hash functions. 

A. h(key) = key%tablesize for tablesize a prime number.

B. h(key) = key%tablesize for tablesize a power of 2.

Notations and guidelines: 

  • tablesize is number of unique table indexes that the hash function generates. For example a function key%10 results in 10 unique numbers [0-9] for any valid integer key.
  • Based on the above point you must now realize that tablesize can be determined based on the hash function.
  • Remember that h(key) returns the table index.
  • Use Java's inbuilt random number generator to generate keys.
  • As h(key) returns table index, its return type should be of type int.

Data Structure Implementation: 

  • You must implement a list based hash table. (You must implement your own linked list, do not use Java's LinkedList class).
  • Use Separate Chaining method for resolving hash clash.
  • You can use the following node class definition towards your implementation:

Class Node { 

   int key; 

  int record; 

   Node nextNode; 

 

  • In the node class let your record member hold the value stored in key member.
  • Your FIRST STEP towards creating the data structure will be to create the bucket. Bucket is an array that holds Node objects. The size of bucket will be tablesiz,e recollect that tablesize can be determined based on your hash function as described earlier.
  • Remember that hash function returns the bucket index. Based on the index returned by hash function the record must be inserted accordingly.
  • Note that random number generator may return same number multiple times, so you must check if a key already exists. Insert they key only if it does not exist in the hash table.

Reference no: EM13351132

Questions Cloud

In january 2009 anna entered in a contractual agreement : in january 2009 anna entered in a contractual agreement with penguin ltd to prepare a book on indian recipes for
1 salem corporation uses the calendar year as its tax and : 1. salem corporation uses the calendar year as its tax and financial annual accounting period. management because of
Problem 1the average prices for a product in 12 stores in a : problem 1the average prices for a product in 12 stores in a city are given
Part-1prepare a program that teaches arithmetic to a young : part-1prepare a program that teaches arithmetic to a young child. the program tests subtraction and addition. in level
Given a hash function hkey prepare a java simulation : given a hash function hkey prepare a java simulation program to determine each of the subsequent quantities after
Q1 for the beam given in the figure below assume that the : q1. for the beam given in the figure below assume that the material is astm-a514 steel with elastic modulus and e
A horizontal 500 lb force performs at a point d of : a horizontal 500 lb force performs at a point d of crankshaft ab which is held in static equilibrium by a twisting
Q1 an s corporation is subject to the following taxa : q1. an s corporation is subject to the following tax.a. corporate income tax. b. built-in gains tax. c. accumulated
Q1 a piece of granite is thrown upward with a speed of 25 : q1. a piece of granite is thrown upward with a speed of 25 ms from a cliff that is 80 m high. how much time goes by

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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