Question

1. (Basic) What is the main advantage of hash tables over direct-address tables? 2. (Basic) What is the assumption of simple

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION:

From given data,

(1)What is the main advantage of hash tables over direct-address tables.

Chaining: Unlimited number of elements are allowed in the chaining.

Unlimited numbers of collisions are possible.

Overflow Area: Provides quite fast access

Collisions do not use primary table space.

Re-Hashing: Has the edge of fast re-hashing.

Provides access through use of main table space.

2)What is the assumption of simple uniform hashing

The assumption is that in a hash table in which collisions are mostly resolved by chaining operations, the

average time for a successful search is case time ⊖(1+load factor).

As, we know that Load Factor = No. of stored elements / No. of Slots

The expected number of elements in a chain is given by this load factor with the uniform hashing method.

So the search can be at most number of elements * load factor + time taken by the hash function to hash a search

element to the given bucket which is a constant.


3) Why the hash function h(k) = k mod 2L for some integer L is not desirable

Hash tables consist of mainly two components:

- bucket array

- hash function.

An array of size "m" (here m = 2L ) can be used to represent the dictionary. Here each entry is thought of a bucket.

The prime drawback of this is that size of bucket array is the size of set from which the key is drawn, which may be

huge.

Here, when the value of integer L is increased beyond a limit, it makes hashing operation cumbersome, inefficient

and time taking.

Hence, hash function h(k) = k mod 2L for some integer L is not desirable.

The simplest hash function which is used to limit the size of the array and to make the hashing efficient is:

h(k) = k mod m

where k can be very large, and m can be very small as we want it to be.

Please thumbs-up / vote up this answer if it was helpful. In case of any problem, please comment below. I will surely help. Down-votes are permanent and not notified to us, so we can't help in that case.

Add a comment
Know the answer?
Add Answer to:
1. (Basic) What is the main advantage of hash tables over direct-address tables? 2. (Basic) What...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assume a Hash table has 7 slots and the hash function h(k) = k mod 7...

    Assume a Hash table has 7 slots and the hash function h(k) = k mod 7 is used. The keys 14, 3, 11, 6, 10, 4, 20, and 17 are inserted in the table with collision resolution by chaining. Assume that the keys arrive in the order shown. (a) Show the hash table obtained after inserting all 8 keys. [Show only the final table] (b) Under the assumption that each key is searched with probability 1/8, calculate expected number of...

  • 11. Dra The size The hash function used is: the contents of the 13 hash tables...

    11. Dra The size The hash function used is: the contents of the 13 hash tables below. Show your work for partial r hash table is HOk)-k mod 7 13, 17, 6, 24, 3 a) Resolve collisions with chaining b) Double hashing, where W20)-7-0mod 5) 0 1 1 2 2 3 3 4 4 5 5 6 6 c) What is the load factor for the table a? d) What is the load factor for the table b? f) Is...

  • Consider a hash function hashing a key K to a table of n buckets (indexed from...

    Consider a hash function hashing a key K to a table of n buckets (indexed from 0 to n - 1). Which of these would be acceptable hash functions -- meaning that they would work correctly for both insertions and searches? Assume the function Random(n) returns an integer between 0 and n - 1, inclusive. (Select all that apply). Group of answer choices 1. h(K) = k mod n 2. h(K) = Random(n) 3. h(K) = n 4. h(K) =...

  • 4. Hashing and Hash Tables. You need to use the ASCII table in the last page for this question. Study the following hash functions for ASCII C strings that are at least 3-char long unsigned hash1(con...

    4. Hashing and Hash Tables. You need to use the ASCII table in the last page for this question. Study the following hash functions for ASCII C strings that are at least 3-char long unsigned hash1(const char, unsigned unsigned vto]+01997 return (v % m); unsigned hash2Cconst char unsigned) unsigned v-o]k(2] 877 return 1 + (v % ( -1)); (a) Given that m-, 7, compute the hash values and fill the following table (3%) String k hash1k, ) hash2(k, 7) aph...

  • 1. Suppose that a hash table contains hash_size = 13 entries indexed from 0 through 12...

    1. Suppose that a hash table contains hash_size = 13 entries indexed from 0 through 12 and that the following keys are to be mapped into the table: 24    34    33    55    46    38    37 The hash function determines the hash address by first summing all digits of a key (in ordinary decimal representation) and then applying % hash_size.    Answer the following questions. Assume that double hashing g(k) = 7 – (k mod 7) is used. Present the hash table...

  • 2. (10 points.) The procedure HASH-SEARCH takes a hash table T[O : m-1) and a key...

    2. (10 points.) The procedure HASH-SEARCH takes a hash table T[O : m-1) and a key k as its parameters. Each element of T is either a key or NIL. The procedure searches for k in T by probing. If it finds k, then it returns the index j where k appears in T. If it cannot find k, then it returns -1. (A procedure very much like HASH-SEARCH is discussed on pages 269–274 of Cormen.) HASH-SEARCH(T, k) i= 0...

  • Insert elements into a hash table implemented using chain hashing, as an array of linked list...

    Insert elements into a hash table implemented using chain hashing, as an array of linked list in which each entry slot is as a linked list of key/value pairings that have the same hash (outcome value computed using certain hash function). You are allowed to use “Hash Function”, h(k) = k % x where, x is the value you will need to decide to use, that you find appropriate for this implementation. The main requirements are the following: 1. Input:...

  • 3. (20 points) In open addressing with double hashing, we have h(k,i) hi(k)+ih2(k) mod m, where h...

    3. (20 points) In open addressing with double hashing, we have h(k,i) hi(k)+ih2(k) mod m, where hi(k) and h2(k) is an auxiliary functions. In class we saw that h2(k) and m should not have any common divisors (other than 1). Explain what can go wrong if h2(k) and m have a common divisor. In particular, consider following scenario: m- 16, h(k) k mod (m/8) and h2(k)-m/2 and the keys are ranged from 0 to 15. Using this hash function, can...

  • 1. What is the main purpose of a presentation? Answer: 2. What is the main advantage...

    1. What is the main purpose of a presentation? Answer: 2. What is the main advantage of speaking over writing? Answer: 3. If you want to persuade your readers, what should you consider doing? Answer: 4. While a persuasive speech might include an appeal to emotion, an informative speech should focus on _________. Answer: 5. As an aid to memory, it’s a good idea to have repetition in your presentation. Think of your presentation as having: an _________that previews, a...

  • 1. What is the purpose of the “hash function” within a hash table? 2. What is...

    1. What is the purpose of the “hash function” within a hash table? 2. What is an example of greedy algorithms in the real world? 3. List some examples of a “divide and conquer” strategy that we may have encountered in our experience

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT