Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help creating the following hash function in C: For this ODP, you are to write a function named hash which accepts a string and

Need help creating the following hash function in C:

image text in transcribed

For this ODP, you are to write a function named "hash" which accepts a string and returns an integer. To calculate the hash, add the ASCII codes of each character in the string. Then reduce the final sum mod 31. Note that to add the ASCII codes, you can simply add each character (i.e. buffer[1]) to a running integer sum. Use "%" for reducing the sum. Here are some sample hashes: A: 3 (A has an ASCII value of 65, and 65%31-3) ABC: 12 (A, B and C have ASCII codes of 65, 66 and 67, 65+66+67 198 and 198%31-12) HELLO: 0 Hello: 4 HELLP: 1 HELLN: 30 Be careful in your testing: strings you read with fgets have a In appendeod to the end, which will change the hash value. The prototype for hash is int hash(char

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

kimberley proccess

Answered: 1 week ago

Question

Understand the role of internal marketing and communications.

Answered: 1 week ago