Introduction to Java Programming, Includes Data Structures, Eleventh Edition, Y. Daniel Liang

This quiz is for students to practice. A large number of additional quiz is available for instructors using Quiz Generator from the Instructor's Resource Website. Videos for Java, Python, and C++ can be found at https://yongdanielliang.github.io/revelvideos.html.

Chapter 27 Hashing


Section 27.2 What Is Hashing?
27.1  A hashing function __________.
A. stores an element in the hash table
B. maps a key to an index in the hash table

27.2  If each key is mapped to a different index in the hash table, it is called _______.
A. normal hashing
B. perfect hashing

27.3  A collision occurs _____________.
A. when two or more keys are mapped to the same hash value.
B. when two elements have the same key value.
C. when two elements are mapped to the same key.

Section 27.3 Hash Functions and Hash Codes
27.4  Every object has the hashCode() method.
A. True
B. False

27.5  What is the return type value for the hashCode() method?
A. byte
B. short
C. int
D. long

27.6  True or False? Two objects have the same hash codes if they are equal.
A. True
B. False

27.7  True or False? Two objects are equal if they are equal.
A. True
B. False

27.8  For an Integer object with value 20, what is its hashCode?
A. 10
B. 20
C. 30
D. 40

27.9  If two strings are equal, the two strings have the same hashCodes.
A. True
B. False

27.10  True or False? Assume N and hashCode are positive and N is an integer of power of 2, hashCode % N is the same as hashCode & (N - 1).
A. True
B. False

27.11  1 & 3 is _________.
A. 0
B. 1
C. 2
D. 3

27.12  1 << 2 is _________.
A. 2
B. 3
C. 4
D. 5

Section 27.4 Handling Collision Using Open Addressing
27.13  When a collision occurs during the insertion of an entry to a hash table, ______ finds the next available location sequentially.
A. linear probing
B. quadratic probing
C. double hashing.

Section 27.5 Handling Collision Using Separate Chaining
27.14  _____________ is to find an open location in the hash table in the event of collision.
A. Open addressing
B. Separate chaining

27.15  The __________ places all entries with the same hash index into the same location, rather than finding new locations.
A. open addressing scheme
B. separate chaining scheme

Section 27.6 Load Factor and Rehashing
27.16  _______ measures how full the hash table is.
A. Load factor
B. Threshold