In Python, implement a hashing table data structure of size 20, which can cope with collisions. Thus, you must implement the closed collision system in its three modes:
Linear scan
Quadratic scan
Double hashing scan. For halt use halt(k)= (k mod (m - 1)) + 1, where m is the size of the table.
The data to be managed are students from a certain university who have a 5-digit registration number and it is unique. In addition, the student has a name, age and address. Create a .txt file with 10 students (one for each line) and have them loaded into your program. Build a menu of options where you can:
- Enter a new student. For this option, that only allows entering the 5-digit license plate and that random data is automatically generated for the name, age and address. Return the position where it was entered and if it is not possible to enter it, print a message that explains why the entry was not obtained.
Step by stepSolved in 2 steps
- Suppose you have a hash table of size N = 64, and you are using quadratic probing. The keys in your hash are 4-digit integers (0000 through 9999) and your hash function is h(k) = (the sum of the digits in k). Assuming keys are uniformly random over the range 0000 to 9999, is this a good hash function? (Answer true for yes, false for no). True Falsearrow_forwardLet us consider a hash table with an underlying array of length 5. It is initially empty, and we then add consecutively the integers: 44, 7, 45, 21, 8, 23, 0, 33 Draw the resulting hashtable after all additions are made. Assume that the hash function used is the remainder of dividing by 5, that is: def hash(d): return d%5 You do not need to consider resizing the underlying array.arrow_forwardConsider a open bucket hash table and closed bucket hash table in which the keys are student identifiers (strings of 6 digits). Assume the following number of buckets and hash function: m = 100; hash(id) = first two digits of id #. Starting with an empty hash table, show the effect of successively adding the following student identifiers: 000014, 990021, 990019, 970036, 000015, 970012, 970023. Use following function as second hash function hash(id) = last digit of id # Show the effect of deleting 000014 from the hash table. (Java Programming DSA)arrow_forward
- I am having a hard time finding the right approach for the question. I need a justified answer. Could you please help me through?arrow_forwardExperiment with hashCode() in Java on a large dataset (of size M) to show that the hash functions distribute keys fairly evenly between 0 to M-1.arrow_forwardI am trying to implement a hash table of key-value pairs, where the key determines the location of the pair in the hash table, the key is what the hash function is used on. The hash table that I am trying to implement will use separate chaining (with unordered linked lists) for collision resolution. I need help changing the code where: 1. The "search" method of the code returns the node that was found or "None" 2. The "Node" implementation has a "key" and "value" member This is what I have so far class Node: def __init__(self,initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self,newdata): self.data = newdata def setNext(self,newnext): self.next = newnext class UnorderedList: def __init__(self): self.head = None def isEmpty(self): return self.head == None def add(self,item): temp = Node(item) temp.setNext(self.head)…arrow_forward
- Assume that linear probing is used for hash-tables. To improve the time complexity of the operations performed on the table, a special AVAILABLE object is used to mark a location when an item is removed from the location. Assuming that all keys are positive integers, the following two techniques were suggested instead of marking the location as AVAILABLE: i) When an entry is removed, instead of marking its location in the table as AVAILABLE, indicate the key in the location as the negative value of the removed key (e.g., if the removed key was 16, indicate the key as -16). Searching for an entry with the removed key would then terminate once a negative value of the key is found (instead of continuing to search if AVAILABLE is used). ii) Instead of using AVAILABLE, find a key in the table that should have been placed in the location of the removed entry, then place that key (the entire entry of course) in that location (instead of setting the location as AVAILABLE). The motive is to…arrow_forwardIf two different keys are hashed to the same location in a too-full hash table (A-1), what will be done by the Open Addressing technique? The table size is doubled (and rehashed) in order to accommodate the keys. Alternative cells are tried until an empty cell is found in the neighborhood. They are chained in two different linked lists at that location. They are chained in the same linked list at that location.arrow_forwardSuppose you have a hash table of size N = 64, and you are using pseudo-random probing. The keys in your hash are 4-digit integers (0000 through 9999) and your hash function is h(k) = (the sum of the digits in k). Assume that the first 4 slots of your pseudo-random probing array contain: 5, 10, 60, 30 What are the first 4 values in the probe sequence (starting with the home position) for a record with key k=1948?arrow_forward
- Suppose you have a hash table with seven entries (indexed 0 through 6). This table uses open addressing with the hash function that maps each letter to its alphabet code (a = A = 0, etc.) modulo 7. Rehashing is accomplished using linear-probing with a jump of 1. Describe the state of the table after each of the letters D, a, d, H, a, and h are added to the table.arrow_forwardIn this task, two hash tables should should be implemented. You can follow the followinginstructions:- In class HashTable implement a hash table and consider the following:(i) Keys are integers (therefore also negative!) and should be stored in the tableint[] data.(ii) As a hash function take h(x) = (x · 701) mod 2000. The size of the table istherefore 2000. Be careful when computing the index of a negative key. Forexample, the index of the key x = −10 ish(−10) = (−7010) mod 2000 = (2000(−4) + 990) mod 2000 = 990.Hence, indices should be non-negative integers between 0 and 1999!(iii) Implement insert, which takes an integer and inserts it into a table. Themethod returns true, if the insertion is successful. If an element is already inthe table, the function insert should return false.(iv) Implement search, which takes an integer and finds it in the table. The methodreturns true, if the search is successful and false otherwise.(v) Implement delete, which takes an integer and deletes it…arrow_forwardConsider a hash table of capacity 5 that uses open addressing with linear probing. This hash table uses a hash function that takes the remainder when the hash code of a string is divided by the capacity of the hash table. (For example, "air" hashes 0.) The hashCode method has been overridden for strings, which simply returns 0 if a string begins with 'a', 1 if it begins with 'b', etc. /** Returns 0 if a String begins with 'a', 1 if it begins with 'b', etc. */ public int hashCode() { return this.charAt(0) - 'a'; } Assume that "apple", and "butter" have been inserted in this order into the hash table. "fig" is to be inserted into the hash table. (a) Which array slot/index should "fig" be placed? Answer: (b) What is the load factor after "fig" is inserted into the hash table? Answer:arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY