Question: this is a only question please try to solve it. it's very imp. 4. Suppose you're in the data organizing committee of your institute. Your

 this is a only question please try to solve it. it's

very imp. 4. Suppose you're in the data organizing committee of your

this is a only question please try to solve it. it's very imp.

4. Suppose you're in the data organizing committee of your institute. Your task is to assign a unique roll number to every student in your institute using the name of the student and store the details into a Hash table H of size 1000. Roll number contains a unique alphabet followed by a numeric id 5 of three digits which can be calculated with the help of a hash function h(k). The first letter of the roll number is the first letter of the student name and the last three digits are the hash numbers generated by the hash function given below. hi(k) = ((sum of the ASCII values of each character in the key k)%26)%10 where hi(k) is the ith digit in the roll number for 1 h1(k)h2(k)h3(k). Now the student name is inserted into the index h1(k)h2(k)h3(k) of H. For example, Abhishek is the given name then 'Abh' are the letters chosen for 1st digit formation, *Ahs' are the letters chosen for 2nd digit formation and 'As are the letters chosen for 3rd digit formation. In the above example, for the 3rd digit formation only two characters are available. So use only these two available characters in this case. Abhishek Oth, 1st and 2nd character Oth, 2nd and 4th character Oth and 4th character Abh Ahs As h() = (65+98+1049%26)%10 = h(k) = ((65+104+115)%26)%10 = 4 h(K) = ((65+115)%26)%10 =4 A744 Figure 2: Formation of roll number for a given example Abhishek h(Abh) = ((65 +98 + 104)%26)%10 = 7 h(Ahs) = (65 + 104 + 115)%26)%10 = 4 h(As) = ((65+115)%26)%10 = 4 Thus, the roll number associated with Abhishek is A744. Now the name Abhishek is inserted into the index 744 of H. 6 Your program should contain the following functions: INSERTDATA (string Name): Inserts Name into the index x of the Hash table H. This function first applies the hash function hi(k) to obtain the roll number associated with the Name, then the three digits in that generated roll number is the index x. SEARCH (string RollNum): Prints the name of the person associated with the user input RollNum. DELETE (string RollNum): Deletes the name of the person associated with the user input roll number from the hash table. Input Format: Each line contains a character from {'i', 's', 'd'} followed by Roll number or Name. Character 'i' is followed by an alphanumeric string, denoting the name. In this case, your program should insert the name into the index obtained from the RollNumber calculated using the hash function. Character 's' is followed by an alphanumeric string, denoting the RollNum. In this case, your program should print the name of the student in the index obtained from the RollNum in H. If the entry corresponding to the index obtained from RollNum is empty, print NOT FOUND. Character 'd' is followed by an alphanumeric string, denoting the RollNum. In this case, your program should delete the name of the student in the index obtained from the RollNum in H. Output Format: The output (if any) of each command should be printed on a separate line. Note: Assume that the Hash table H is free from collision and the deletion operation is always a valid operation. Sample Input: i Abhishek i Anupam i Akshat i Ebin S A744 s E287 S A333 d A744 S A744 Sample Input: Abhishek Ebin NOT FOUND NOT FOUND

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!