Question
What is this hash function?I mean when i try to put keys it gives me a value bigger than my array size so im confused about what to do.Thanks in advance
We have an empty table of 10 element. This is a hash table with hash function ()=(K/100)*3 + K/10. We will use linear probing
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Perform mod 10 in the end, because any hash function usually there is mod TablesSize

I think there the mistakenly forgot to put mod 10 in the hash function.

The hash function must be

h(K) =((K/100) * 3 + K/10) mod 10

-----------------------------------------------------------

Insert the given keys,

Key 2162, h(2162) = (21*3 + 216) mod 10 = 9

Insert 2162 at index 9

Key 7533, h(7533) = (75*3 + 753) mod 10 = 8

Insert 7533 at index 8

Key 1640, h(1640) = (16*3 + 164) mod 10 = 2

Insert 1640 at index 2

Key 9955, h(9955) = (99*3 + 995) mod 10 = 2

Collision, use linear probing, insert at next free slot

Insert 9955 at index 3

Key 3223, h(3223) = (32*3 + 322) mod 10 = 8

Collision, use linear probing, insert at next free slot

Insert 3223 at index 0

Hash table after inserting the keys:

0 3223
1 NULL
2 1640
3 9955
4 NULL
5 NULL
6 NULL
7 NULL
8 7533
9 2162

-------------------------------------------------------------------

I hope this helps you,

Please rate this answer if it helped you,

Thanks for the opportunity

Add a comment
Know the answer?
Add Answer to:
What is this hash function?I mean when i try to put keys it gives me a...
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
  •     Given the above hash function, when using a base=250726 and tablesize=250767, we get alot of...

        Given the above hash function, when using a base=250726 and tablesize=250767, we get alot of collisions and very long probing chains. This results in a longer running time. Why do using these numbers causes the mentioned effect?? Please answer in details with full explanation thank you def hasht (key: str, base: int, table: int) -> int: TI Universal Hash function -post: returns a valid position (0 <= value < table size) - complexity: O(K) where K is the size...

  • 0. Introduction. This involves designing a perfect hash function for a small set of strings. It...

    0. Introduction. This involves designing a perfect hash function for a small set of strings. It demonstrates that if the set of possible keys is small, then a perfect hash function need not be hard to design, or hard to understand. 1. Theory. A hash table is an array that associates keys with values. A hash function takes a key as its argument, and returns an index in the array. The object that appears at the index is the key’s...

  • How to write the insert, search, and remove functions for this hash table program? I'm stuck......

    How to write the insert, search, and remove functions for this hash table program? I'm stuck... This program is written in C++ Hash Tables Hash Table Header File Copy and paste the following code into a header file named HashTable.h Please do not alter this file in any way or you may not receive credit for this lab For this lab, you will implement each of the hash table functions whose prototypes are in HashTable.h. Write these functions in a...

  • Hi can You please solve [t-BuCl] remaining for my table the concentration of it remaining I only...

    hi can You please solve [t-BuCl] remaining for my table the concentration of it remaining I only used time trial attempt 1 heres my data with the table thats not filled in on the picture: for % t-BuCl remaining for trials 2-4: I got 85 % trial 2, 90 % trial 3, and 95% trial 4 for trials 1-4 for time 1st attempt I got 87 seconds trial 1 72 seconds trial 2 35 seconds trial 3 7 seconds trial...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • please correct me If I did anything wrong. im very confused on this. • Determining k...

    please correct me If I did anything wrong. im very confused on this. • Determining k in Beer's Law 2. Determining the equilibrium constant Test Tube No. Absorbance Test Tube No. Absorbance 0,060 이79 0.253 0319 0.400 0.120 0.268 0.361 0.461 0.695 Post Laboratory Questions 1. Complete the following table and calculate k-value for the Beer's Law. All concentrations should be in M. [Fe(SCN)2) Absorbance CA Test Tube No. Diluted Fe(NO3)2 (mL) 0 . 2 3 4 s Reference 1.0...

  • Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a =...

    Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a = [ [93, 80, 99, 72, 86, 84, 85, 41, 69, 31], [15, 37, 58, 59, 98, 40, 63, 84, 87, 15], [48, 50, 43, 68, 69, 43, 46, 83, 11, 50], [52, 49, 87, 77, 39, 21, 84, 13, 27, 82], [64, 49, 12, 42, 24, 54, 43, 69, 62, 44], [54, 90, 67, 43, 72, 17, 22, 83, 28, 68], [18, 12, 10,...

  • Hello can someone please help me with this queshtion its 3 time I post this please....

    Hello can someone please help me with this queshtion its 3 time I post this please. The queshtion is in the buttom. Im really confused from what to choose I have been second guessing myself. The Economics of Immigration Paul Krugman In 1970, only 5% of U.S. workers had been born abroad. By 2016, however, 17% of American workers had immigrated to the United States, both legally and illegally. (1) Figure 1: Percentage of U.S. labor force that is foreign-born...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

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