Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 17.4, Problem 1E
Program Plan Intro
To argue that the dynamic implementation of insertion in open-address hash table runs at
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Exercise 1
Consider a hash table of size 13, and assume open addressing with linear probing
Show what the hash table will look like after the following items are added in the order shown.
26 54 77 90 27 30 28 52 96 65
What’s the load factor of the hash table after the values above are added?
If any of the values cause a collision, indicate which.
How many comparisons are needed to find 65 in the table? Briefly explain.
How many comparisons are needed to determine that 104 is not in the table? Briefly explain.
What’s the hash value computed for the string “dog”? Show your work.
Exercise 2
Suppose chaining is used as the method for collision resolution.
Part A
Show what the hash table will look like after the following items are added in the order shown.
26 54 77 90 27 30 28 52 96 65
How many comparisons are needed to find 65 in the table?
How many comparisons are needed to determine that 104 is not in the…
a) Consider inserting the keys 10, 22, 31, 4, 15, 28, 17,
88, 59 into a hash table of length m = 11 using open
addressing with linear probing, we use the hash
function h(k, i) = (k+ i) mod m.
Given input {4371, 1323, 6173, 4199, 4344, 9679, 1989} and a hash function h(x) = x mod
10, show the resulting open addressing hash table:
(ii) with second hash function h2(x) = 7 – (x mod 7).
Please show me the steps
Knowledge Booster
Similar questions
- Consider a hash table with open addressing with 11 slots. Using the hash function h(x) = x mod 11, insert the keys (52,44,56,61,64) into the table in the same order. Assume that keys 0,1,8,9 already in the table .Use Linear probing and Quadratic probing for collision resolution Show the results in the two separate tablesarrow_forward10. Consider a hash table that uses the linear probing technique with the following hash function f(x) = (5x+4)%11. (The hash table is of size 11). If we insert the values 3, 9, 2, 1, 14, 6, and 25 into the table, in that order, show where these values would end up in the table? Show all the calculations and actions that needs to perform for the values to be stored. index 0 1 2 3 4 5 8 9 10 valuearrow_forwardConsider a linear hash table that uses 4-bit hash keys and stores two records per bucket. The capacity threshold is 75%; that is, we create a new bucket whenever the number of records is more than 3/2 the current number of buckets. Simulate the insertion, into an initially empty hash table, of records with (hash values of) keys 1111, 1110, 1101,..., 0001, 0000, in that order. Which of the following keys never appears alone in a bucket at any time during the insertion sequence? a) 1110 b) 1011 c) 0100 d) 1001arrow_forward
- Consider an extensible hash table that uses 4-bit hash keys and stores two records per bucket. Simulate the insertion, into an initially empty hash table, of records with (hash values of) keys 1111, 1110, 1101,..., 0001, 0000, in that order. Which combination of i (the number of bits used to index the bucket array) and a set of of keys belong to one bucket at some time during the sequence of insertions? Group of answer choices i = 1; 1110 only. i = 3; 0101 only. i = 2; 1111 only. i = 3; 1000 only.arrow_forwardConsider a linear hash table that uses 4-bit hash keys and stores two records per bucket. The capacity threshold is 75%; that is, we create a new bucket whenever the number of records is more than 3/2 the current number of buckets. Simulate the insertion, into an initially empty hash table, of records with (hash values of) keys 1111, 1110, 1101,..., 0001, 0000, in that order. Which of the following keys never appears alone in a bucket at any time during the insertion sequence? Group of answer choices 1010 1001 1110 0011arrow_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
- Consider a hash table of capacity 4 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 "cherry" have been inserted in this order into the hash table. "guava" is to be inserted into the hash table. (a) Which array slot/index should "guava" be placed? Answer: (b) What is the load factor after "guava" is inserted into the hash table? Answer:arrow_forwardpython In simple uniform hashing, each key is assumed to have equal probability to map to any ofthe hashes in a given table of size m. Given an open-address table of size 100 and 2random keys, what is the probability that they hash to the same value? What is theprobability that they hash to different values?arrow_forwardHelp me pleasearrow_forward
- Consider a CBHT (closed bucket hash table) in which the keys are student identifiers. Assume that the number of buckets m = 100 and hash function 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, and 970023. Show the effect of deleting 000014 from the hash table.arrow_forwardSuppose we want to store a set S of n keys in a hash table T with size m, with m = n + 2, and a hash function that behaves uniformly. Should we resolve collisions with chaining or with open- addressing? Please explain why.arrow_forwardConsider Cuckoo hashing with a hash table H[0... 10] and the two hash functions: h₁(x) = (x +2) mod 11 h₂(x) = (4x + 1) mod 11. (When inserting, try h₁ first.) Consider the following sequence of operations: Insert(11) Insert(13) Insert(33) Which position is 33 placed in? 0 1 2 3 4 5 6 O O ос 7 8 9 10arrow_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