Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a HashTable for integers using open hashing to represent sets of integers. You must implement the hash table yourself and are not allowed to

Implement a HashTable for integers using open hashing to represent sets of integers.

You must implement the hash table yourself and are not allowed to use the C++ standard

template library, i.e., you will need to implement a class for the set. Your set must provide

the basic set operations as discussed in class (add, delete, search, show, quit). Each

element of the set will be stored in a node object, i.e. you will need a separate class that

handles the nodes.

Upon starting your program, it will display the following prompt: set> (followed by a

space):

set>

The user can then add, delete, search, or show the set. If the element is already in the

set and you attempt to add that element to the set, then you need to display an

informational warning message. Similarly, if the element is not already in the set and you

attempt to delete that element from the set, then you need to display an informational

warning message.

Your hash table will have B=7 buckets and your hash function is h(x) = x^2 mod B.

FUNCTION DETAILS:

add will insert a number into the set and is followed by the prompt. If the element is

already in the set, provide an informational message WARNING: duplicate input: #

set> add 7

set> add 7

WARNING: duplicate input: 7

set> add 3

set>

delete will delete an element, if it is in the set. If the element does not exist, provide an

informational message WARNING: target value not found: #

set> delete 3

set> delete 8

WARNING: target value not found: 8

set>

search will return true or false to indicate if the element has been found

set> search 7

true

set> search 4

false

set>

show will list all the elements of the hash table in the following form:

set> show

()-()-()-()-()-()-()

set>

The parenthesis will contain the elements of the individual buckets, separated by

commas. The above example is the empty set

Assume the hash table contains the following elements (order of insertion matters, since

elements are appended at the end of a list for each bucket)

set> add 1

set> add 2

set> add 3

set> add 4

set> add 5

set> add 6

set> add 7

set> show

(7)-(1,6)-(3,4)-()-(2,5)-()-()

set>

quit will exit the program

set> quit

image text in transcribedimage text in transcribed
1.1 Matching: Computability Theory Deals with the definitions and properties of mathematical models of computation Complexity Theory What are the fundamental capabilities and limitations of computers? Automata Theory What makes some problems computational hard and others easy? 1.2 The three basic set operations are union, _and 1.3 T/F: Does ( E ()? 1.4 Let A={0,1). Then | |A3 | | = (a) 1 (b) 2 (c) 6 (d) 8? 1.5 T/F: The following function f: {0,1,2,3} -> {A,B,C,D,E) is one-one; is onto. (Answer: both are false.) N f(n) 0 D B 2 C 3 A 1.6 T/F: The beats relation we just covered is an equivalent relation. 1.7 Given an undirected graph with n vertices, how many edges can it have at most? (a) 2n (b) n? (c) n(n-1)/2 (d) n! 1.8 Which of the following string does not belong to the language L = {w| |w| is even or w begins with 0}? (a) A (b) 10 (c) 0 (d) 1 1.9 T/F: The value of (0 V 1) A (1 V 1) is 0.An alternative method for implementing a set S is to imitate the bit string implementation of Delphi by using a boolean array S where S[ch] is true if the element ch is in S and is false otherwise. Using this implementation, write functions for the basic set operations of union, intersection, difference, membership, and equality. The rules for the program are: 1) Declare a boolean array type which will be mapped from 'A' to 'Z'. Note that the subscripts are characters so that we can actually test S[ch] directly M loop from 'A' to '2' directly in the for loop. 2) Create three arrays which will mimic sets: UNIVERSAL, VOWEL and MYNAME. Call a function INIT to initialize these arrays, with UNIVERSAL holding all of the letters, VOWEL contains the letters A, E, I, O and U. Initialize MYNAME to be an empty set, then read a data file which will contain the letters in your name. For ease of input, you can put one letter on each line. 3) Create a print function which will be sent one array. The print will be across a row with a space between elements, as in the following format: ABCDEFGHIJKLMNOPQRSTUWXYZ Call it three times to print the members of UNIVERSAL, VOWEL, and MYNAME, printing an appropriate message each time. 4) Write a function which will find the union of any two sets sent to it. Test the function by having it union VOWEL and MYNAME. Call the print function to print this set with an appropriate message

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_2

Step: 3

blur-text-image_3

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

Applied Calculus

Authors: Stefan Waner, Steven Costenoble

6th Edition

1285415310, 9781285415314

More Books

Students also viewed these Mathematics questions