Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 27.4, Problem 27.4.6CP
Program Plan Intro
Open Addressing:
- Open addressing is a method of finding an open location in the hash table at the time of collision.
- There are several variations for open addressing such as linear probing, quadratic probing, and double hashing.
Double Hashing:
- One other open addressing method that can avoid the clustering problem is referred as double hashing.
- In order to avoid the clustering problem, double hashing method uses a secondary hash function on the keys to determine the increments.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
3.
Double hashing is one of the methods to resolve collision. Write a function to
implement this method. The equations used in this method are given below. Note:
implement everything within the double hash function.
P = (P + INCREMENT(Key)) mod TABLE_SIZE
INCREMENT(Key) = 1 + (Key mod INCR)
Insert keys {10, 22, 11, 31, 24, 88, 38, 21} into an empty hash table with CAPACITY = 10 using quadratic probing (c1=0 and c2=1) to resolve collision (You shouldn't use a for/while loop except to increment the value of i for quadratic probing). Use the hash function is h(k, i) = (h’(k) + c1* i + c2* i^2) mod 10 and h’(k) = k mod 10.
Draw a hash table given these numbers and hashing function, build each of the hashing
options, and decide if it is efficient, and what function or size might be a better match. Explain
why it is efficient or what changes you would make for it to be efficient.
a. Scenario 1
a. Hashing function: k mod 4
b. Linear Probing
c. Array from 0 to 3
d. Values: 19, 7, 12, 11
b. Scenario 2
a. Hashing function: k mod 10
b. Quadratic Probing
c. Array from 0 to 9
d. Values: 20 39 23 56 34 29 55 13
c. Scenario 3
a. Hashing function: first three digits of a phone number
b. Overflow chaining
c. File with base address of 0 and ends at 999
d. Values: 3135552314, 7343455523, 3134445555, 3134441234, 7342346555,
e. 5555342232, 4072984555, 2692185552
d. Scenario 4
a. Hashing function: k mod 100
b. Internal Chaining
c. Array 0 to 99
d. Values: 314 325 623 2234 425 1234 2132 2361 1245 123 436 742
Chapter 27 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 27.2 - Prob. 27.2.1CPCh. 27.3 - Prob. 27.3.1CPCh. 27.3 - Prob. 27.3.2CPCh. 27.3 - Prob. 27.3.3CPCh. 27.3 - Prob. 27.3.4CPCh. 27.3 - Prob. 27.3.5CPCh. 27.3 - Prob. 27.3.6CPCh. 27.3 - If N is an integer power of the power of 2, is N /...Ch. 27.3 - Prob. 27.3.8CPCh. 27.3 - Prob. 27.3.9CP
Ch. 27.4 - Prob. 27.4.1CPCh. 27.4 - Prob. 27.4.2CPCh. 27.4 - Prob. 27.4.3CPCh. 27.4 - Prob. 27.4.4CPCh. 27.4 - Prob. 27.4.5CPCh. 27.4 - Prob. 27.4.6CPCh. 27.5 - Prob. 27.5.1CPCh. 27.6 - Prob. 27.6.1CPCh. 27.6 - Prob. 27.6.2CPCh. 27.6 - Prob. 27.6.3CPCh. 27.7 - Prob. 27.7.1CPCh. 27.7 - What are the integers resulted from 32 1, 32 2,...Ch. 27.7 - Prob. 27.7.3CPCh. 27.7 - Describe how the put(key, value) method is...Ch. 27.7 - Prob. 27.7.5CPCh. 27.7 - Show the output of the following code:...Ch. 27.7 - If x is a negative int value, will x (N 1) be...Ch. 27.8 - Prob. 27.8.1CPCh. 27.8 - Prob. 27.8.2CPCh. 27.8 - Can lines 100103 in Listing 27.4 be removed?Ch. 27.8 - Prob. 27.8.4CPCh. 27 - Prob. 27.1PECh. 27 - Prob. 27.2PECh. 27 - (Modify MyHashMap with duplicate keys) Modify...Ch. 27 - Prob. 27.6PECh. 27 - Prob. 27.7PECh. 27 - Prob. 27.8PECh. 27 - Prob. 27.10PECh. 27 - Prob. 27.11PECh. 27 - (setToList) Write the following method that...Ch. 27 - (The Date class) Design a class named Date that...Ch. 27 - (The Point class) Design a class named Point that...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Use python language for this task Given an array containing Strings, you need to write a code to store them in a hashtable. Assume that the Strings contain a combination of capital letters and numbers, and the String array will contain no more than 9 values.Use the hash function to be the (total number of consonants*24 + summation of the digits) %9. In case of a collision, use linear probing. For a String “ST1E89B8A32”, it’s hash function will produce the value=(3*24+(1+8+9+8+3+2))%9=4, hence it will be stored in index 4 of the hash table. Note: Hash function calculation, method properly written Linear probing properly implementedarrow_forwardSuppose you have a hash table of size N = 256, and you are using double hashing. The keys in your hash are 4-digit integers (0000 through 9999) and your hash function is h(k) = (k²)%N The second hash function (used for probing) is h₂(k) = (sum-of-digits (k) * 8)%N What are the first 4 values in the search sequence (starting with the home position) for a record with key k-2025?arrow_forwardCourse: Data Structure and Algorithms Language: Java Kindly something and Answer in 1 hour. Read Carefully and give answer with all necesary details. See the image for askii codes. Question6: In this Problem, you are required to insert some keys into a hash table, using given hash functions. You have to Draw a Hash table with the inserted keys. Write total number of collisions encountered when a particular collision resolution technique is used. size= 13, H(X) = sum of Ascii codes of key % HTSIZE Keys: Mia, Bea, Zoe, Jan, Ada, Sam, Leo, Meo, Ben, Tim, Ted, Zod Use Linear probing: H’(X) = [H(X) +f(i))] % HTSIZE where f(i)=i where i=0,1,2,….arrow_forward
- Assume a hash table utilizes an array of 13 elements and that collisions are handled by separate chaining. Considering the hash function is defined as: h(k)=k mod 13. i) Draw the contents of the table after inserting elements with the following keys: 36, 243, 261, 180, 217, 180, 21, 16, 182, 202, 91, 97, 166, 78, 33, 70, 51, 58.arrow_forwardUsing chained hashing. You have a Hash table of size 7. You will add the following elements in the order given using the function %5. 18 - 44 - 31 - 11 - 8 А. 1 44 31 18 11 В. 3 4 6. 44 11 18 31 8 С. 1 3 4 6. 31 18 44 11 8. D. The correct answer is not listed 00 00 B.arrow_forwardTask on Hashing Given an array containing Strings, you need to write a code to store them in a hashtable. Assume that the Strings contain a combination of capital letters and numbers, and the String array will contain no more than 9 values.Use the hash function to be the (total number of consonants*24 + summation of the digits) %9. In case of a collision, use linear probing. For a String "ST1E89B8A32", it's hash function will produce the value=(3*24+(1+8+9+8+3+2))%9=4, hence it will be stored in index 4 of the hash table.arrow_forward
- Task on Hashing Given an array containing Strings, you need to write a code to store them in a hashtable. Assume that the Strings contain a combination of capital letters and numbers, and the String array will contain no more than 9 values.Use the hash function to be the (total number of consonants*24 + summation of the digits) %9. In case of a collision, use linear probing.For a String “ST1E89B8A32”, it’s hash function will produce the value=(3*24+(1+8+9+8+3+2))%9=4, hence it will be stored in index 4 of the hash table. Instructions Complete the following problem using concepts of Key index searching,sorting and hashing You may use JAVA or PYTHON to complete the tasks. If you are using JAVA, you must include the main method as well which should test your other methods and print the outputs according to the tasks. If you are using PYTHON, make sure your code has the methods invoked and proper printing statements according to the tasks.arrow_forwardSuppose you have a hash table of size N = 64, and you are using quadratic probing with c1 = 1 and c2 = 1. 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). What are the first 4 values in the search sequence (starting with the home position) for a record with key k=1948? Blank # 1 Blank # 2 Blank # 3 Blank # 4arrow_forwardGiven a hash table of size 8, and the hash table uses haah() +i+ in the i-th probe for collsion resolution, what are the indexes of the following elements in the table if the elements are inserted into the table in the following order: String hashCode 79 111 81 "W 87 66 7. "g 2arrow_forward
- Generate 11 unique random elements and perform the extendible hashing. The bucket size is three (3) and the Hash function is the following: H(X) => Suppose the global depth is X. Then the Hash Functi9on returns X LSBs. Make sure that in every hashing step there is an equivalent explanation.arrow_forward3. Given the following keys: 68, 39, 89, 28, 79 Take alpha = 0.6 Compute m (size of hash table), and select it to be a prime number. Now illustrate how you would construct the hash table. Use double hashing as collision resolving technique. The original hash function, is h(k)= k mod m The second hash function for double hashing, h₂(k)=8-(k mod 8)arrow_forwardDraw the contents of the hash table given the following conditions: The size of the hash table is 25. • Linear Probing is used to resolve collisions. • The hash function H(k) should be calculated in the following way where k is the element to be hashed: R(k) = k mod (summation of last two digits of your student id + 7) If R(k)<10 H(k)=R(k) + 8 else H(k)=R(k) - 4 What values will be in the hash table after the following sequence of insertions? 55, 65, 8, 18, 20, 11, 56, 27, 15, 167 [Note: Draw the values using a hash table and show your work for partial credit.]arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education