Question

Name: Hash Tables CS 2020 Hw 14 edefine MAX CAPACITY 11 #define R struct HashTable f int hashtable[MAX CAPACITY]: 1/ table to
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 hash 1 function use and linear probing

Element index (Element % 11) Linear probing
1 1
5 5
4 4

11

0
21 10
15 4 (collision occurred)

4+1 =5(collision occurred)

5+1=6

15 will be stored at 6th location

22 0(collision occurred)

0+1=1 (collision occurred)

1+1=2

22 will be stored at 2nd location

23 1(collision occurred)

1+1=2(collision occurred)

2+1=3

23 will be stored at 3rd location

Elem 11 1 22 23 4 5 15 21
index 0 1 2 3 4 5 6 7 8 9 10

2)

  • There are 2 collisions for inserting 15.
  • There are 2 collisions for inserting 22.
  • There are 2 collisions for inserting 23.

============================================================================================

3) hash 1 function, hash 2 function use and linear probing

primary hash function: hash1

secondary hash function: hash2

Element index (Element % 11) hash2 function and Linear probing
1 1
5 5
4 4

11

0
21 10
15 4 (collision occurred)

hash2(15)=5

i=1

4+5 =9

15 will be stored at 9th location

22 0(collision occurred)

hash2(22)=3

i=1

0+3=3

22 will be stored at a 3rd location

23 1(collision occurred)

hash2(23)=2

i=1

1+2 =3 (collision occurred)

i=2

1+2*2= 5(collision occurred)

i=3

1+3*2 =7

23 will be stored at 7th location

Elem 11 1 22 4 5 23 15 21
index 0 1 2 3 4 5 6 7 8 9 10

4)

  • There is 1 collision for inserting 15.
  • There is 1 collision for inserting 22.
  • There are 3 collisions for inserting 23.
Add a comment
Know the answer?
Add Answer to:
Name: Hash Tables CS 2020 Hw 14 edefine MAX CAPACITY 11 #define R struct HashTable f...
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
  • Hash Tables. (Hint: Diagrams might be helpful for parts a) and b). ) When inserting into...

    Hash Tables. (Hint: Diagrams might be helpful for parts a) and b). ) When inserting into hash table we insert at an index calculated by the key modulo the array size, what would happen if we instead did key mod (array_size*2), or key mod (array_size/2)? (Describe both cases). Theory answer Here Change your hashtable from the labs/assignments to be an array of linkedlists – so now insertion is done into a linkedlist at that index. Implement insertion and search. This...

  • Type up and get the Hash table on pages 19 - 22 to work. Show your...

    Type up and get the Hash table on pages 19 - 22 to work. Show your sample test run at the bottom of your code using a multiline comment I typed everything but the code is not working please help me fix the mistakes. These are pages 19-22. The code I have: #include <iostream> #inlcude <iomanip> #include <stack> #include <vector> #include <cstdlib> #include <ctime> using namespace std; //////////////////////////////HASH TABLE/////////////////////////////////////////////// //hash.cpp //demonstrate hash table with linear probing /////////////////////////////////////////////////////////////////////////////////////// class DataItem {...

  • Project Description Allow the user to specify M (the size of the hash table) then, (1)...

    Project Description Allow the user to specify M (the size of the hash table) then, (1) add items found in text file "Project1.txt" to h, an initially-empty instance of a HASH (reject all items that have a key that duplicates the key of a previously added item—item keys must be unique); (2) display h (see format shown below); (3) delete 4 randomly-chosen items from the h; and finally, (4) display h. Note M must be a prime number, so your...

  • Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and...

    Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods.    Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement   Element to be found */ int findAll(int...

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