question 1 a to d 2 points each here are four attempts to define a has
a to d, 2 points each.
Here are four attempts to define a hash function. For each of them say
whether they are good or bad, and briefly explain why.
A unsigned int Ahaah (steing al
Tunsigned int h 137
unsigned int ns.length
for (int i = 0; i < 1+12
h += s;
return size: 1
B unsigned int Shashietring =)
I unsigned int h = 63443;
for (int & C; i < mi +1
return size; }
Define in C++:
signed int Chash(strings)
(unsigned int h 752711
for (int i=0; i<n; i+ 11
hh 159 + 5111;
D in Dhash(strings)
e, 25 points.
A CircusAnimal is to be represented as an object with the following members:
Two strings, for its name and species.
Two ints, for its purchase price and the number of children it has eaten.
The Circus Database Manager has decided that the CircusAnimal objects
must be stored in a Hash Table organised so that the details of an animal can
be found quickly if its name and species are known. Fortunately, no two
animals of the same species ever have the same name, and no circus animals.
have a zero price, not even the clowns.
for (int i = 0; i < / 111
if it < 0) hh/
return hi I
The classes or structs required for the hash table,
A constructor for the hash table.
A method void add(string, string, int, int) for adding a new animal, and
A method double efficiency(string, string which when provided with
the name and species of an animal, return its efficiency. The efficiency
of a circus animal is of course the number of children it has eaten
divided by its price.
You do not need to write the hash function, just assume that a good one has
Example of use:
f hashtable H;
H.add("timmy", "tiger", 7500, 61:
H.add("priscilla", "dancing horse", 800, 2);
H.add("stubbo", "clown", 45, 0);
cout << H.efficiency ("cimmy", "tiger");
// prints 0.0008
*The amount will be in form of wallet points that you can redeem to pay upto 10% of the price for any assignment. **Use of solution provided by us for unfair practice like cheating will result in action from our end which may include permanent termination of the defaulter’s account.Disclaimer:The website contains certain images which are not owned by the company/ website. Such images are used for indicative purposes only and is a third-party content. All credits go to its rightful owner including its copyright owner. It is also clarified that the use of any photograph on the website including the use of any photograph of any educational institute/ university is not intended to suggest any association, relationship, or sponsorship whatsoever between the company and the said educational institute/ university. Any such use is for representative purposes only and all intellectual property rights belong to the respective owners.