a hashing question

solving for a hash function

Page 1 of 1

5 Replies - 2194 Views - Last Post: 30 April 2008 - 12:27 AM Rate Topic: -----

#1 wiIbur   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 25-September 07

a hashing question

Posted 29 April 2008 - 11:41 PM

On a recent exam, my prof gave us a list of data (8 total) and each corresponding hash index. What I was to find was the hash function. How in the world does one go about doing such a thing?

An example of the data he presented:

h(1141) = 1
h(7732) = 5
h(9455) = 3
etc...

Thank you.
Is This A Good Question/Topic? 0
  • +

Replies To: a hashing question

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: a hashing question

Posted 29 April 2008 - 11:49 PM

I thought the point of a hash was to be unable to find the equation (if it was a "good" hash)
Was This Post Helpful? 0
  • +
  • -

#3 wiIbur   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 25-September 07

Re: a hashing question

Posted 30 April 2008 - 12:02 AM

View PostKYA, on 29 Apr, 2008 - 11:49 PM, said:

I thought the point of a hash was to be unable to find the equation (if it was a "good" hash)


well this function can obviously be found easily if it's on an exam. but yea, you are right. what a retarded question. i should just write the answer you just gave me on the test.
Was This Post Helpful? 0
  • +
  • -

#4 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: a hashing question

Posted 30 April 2008 - 12:08 AM

That's what I would do :), but let's see if we can work this out. The has is applied to the number in () and the result is on the right side of the equals....


HMMMM....

I would look at the whole list (can you post it?) and see if a relationship can be determined among the answers. The type of program using this hash would also be helpful since often hashs are made with similariity to the program in order to eliminate duplicates.
Was This Post Helpful? 0
  • +
  • -

#5 wiIbur   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 25-September 07

Re: a hashing question

Posted 30 April 2008 - 12:20 AM

it's actually an exam question i do not have access to at the moment.

i just realized something. our linear probing has to have at least an 80% loading factor, which means for 8 data keys, we need 10 slots. the function key%10 + 1 should fill slots 1-10. really the only function we have worked with is mod, and i found some notes in which he describes doing it in this way.

this works. but thanks for your help.
Was This Post Helpful? 0
  • +
  • -

#6 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: a hashing question

Posted 30 April 2008 - 12:27 AM

Glad it hopefully will work out to be a lot less complicated then i was imaginating :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1