Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Notifications Mark All Read
No New notification
June 23, 2019
Question 1
46, 42, 34, 52, 23, 33
46, 34, 42, 23, 52, 33
34, 42, 23, 52, 33, 46
42, 46, 33, 23, 34, 52
Good Job!
Oops!
The sequence (A) doesn’t create the hash table as the element 52 appears before 23 in this sequence. The sequence (B) doesn’t create the hash table as the element 33 appears before 46 in this sequence. The sequence (C) creates the hash table as 42, 23 and 34 appear before 52 and 33, and 46 appears before 33. The sequence (D) doesn’t create the hash table as the element 33 appears before 23 in this sequence.
Please login to submit your explanation
Login to see your performance analytics by signing in
Start
Question 2
A function has allocated memory to keys
A function that computes the location of the key in the array
A function that creates an array
None of the mentioned
A hash function is a function that takes a set of inputs of any arbitrary size and fits them into a table or other data structure that contains fixed-size elements. The table or data structure generated is usually called a hash table.
Question 3
O(n)
O(logn)
O(nlogn)
O(1)
Since every key has a unique array position, searching takes a constant time
Question 4
Make the hash function appear random
Use the chaining method
Use uniform hashing
All of the mentioned
Making the hash function random is not really a good choice, although it is considered one of the techniques to avoid collisions along with chaining and simple uniform hashing. Chaining is the best
Question 5
40
2
5
10
For each entry probability of collision is 1/20 {as possible total spaces =20, and an entry will go into only 1 place} Say after inserting x values probability becomes ½ (1/20).x = ½ X=10
Question 6
1
3
unlimited till bucket is found
The key is hashed twice; first by hashCode() of Object class and then by internal hashing method of HashMap class.
Question 7
True
False
Hashmap outputs in the order of hashcode of the keys. So it is unordered but will always have same result for same set of keys.
Question 8
Collection interface provides add, remove, search or iterate while map has clear, get, put, remove, etc. Map interface is the HashMap. It is a hash table based implementation of the Map interface. It implements all of the Map operations and allows null values and one null key. Also, this class does not maintain any order among its elements.
Question 9
HashMap
HashTable
EnumMap
Vector
Vector implements AbstractList which internally implements Collection. Others come from implementing the Map interface.
Question 10
Reference equality
Name equality
Hashcode equality
Length equality
IdentityHashMap is rarely used as it violates the basic contract of implementing equals() and hashcode() method.
Please login to report
Login/Signup to comment
Get Hiring Updates right in your inbox from PrepInsta
Login/Signup to comment