Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to simulate a Separate Chaining Hash Table. The input data specifies the size of the table and includes data to insert, delete,

Write a program to simulate a Separate Chaining Hash Table. The input data specifies the size of the table and includes data to insert, delete, and to findnd. The table size will not be larger than 16381, and will always be prime. The load factor, will not exceed 10.

**The examples are in Java but i want this in C++.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write a program to simulate a Separate Chaining Hash Table. The input data specifies the size of the table and includes data to insert, delete, and to find. The table size will not be larger than 16381, and will always be prime. The load factor, will not exceed 10 Create the following classes class Node private Node next; // the linkage in the singly linked list private String key; // the key of the element private long value; // the data stored Node(String ky, long val, Node nxt); // constructor class LinkedList f Node head; boolean insert (String key, long value); I/ insert at head, or // do nothing, and return false if key is already present boolean delete (String key); // return false if key doesn't exist boolean find(String key); // return result of the search LinkedList); // constructor class HashTable f LinkedList 0 L; II uses an array of (your) LinkedLists HashTable(int size); boolean insert (String key, long val); boolean delete (String key); long search(String key); void clearTable) int size); // constructor // attempt to insert a record. Return false if // the key is already present in the table // attempt to delete a record. Return false if // the key isn't present in the table // attempt to find a record. Return the value // or -1 if the key is not found // empty the hash table // returns the number of records in the table The insert, delete, and search functions will employ a function static int hash(String key, int tableSize); The function will return the int (key.charAt (i) 31 n-i-1 mod 232) | mod 232 | mod tableSize i-0 where there are n characters in the key. So if the key is ABCD the hash function will return ((65x313 mod 232)+(66x312 mod 232)+(67x311 mod 232)+(68x310 mod 232)) mod 232 mod tableSize 1. Use Horner's rule to simplify the computation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago

Question

3. Describe the strategic training and development process.

Answered: 1 week ago

Question

10. Microsoft Corporation

Answered: 1 week ago