Discussion:
Project 1 Question
(too old to reply)
prashant
2005-01-08 21:41:49 UTC
Permalink
I was having problem understanding the method requirements for "int
HashCode()" function. Could someone explain what the method does (examples
might help).



Thanks

- Prashant
Adam Bertrand
2005-01-09 21:49:43 UTC
Permalink
Basically, you want something that will generate a different integer for
each possible rational number you enter, at least, that's what I'm
getting out of it...granted that such an algorithm is technically
impossible, there are acceptable collision rates. We'll cover hashing a
bit later on, I think.

- Adam Bertrand
Post by prashant
I was having problem understanding the method requirements for "int
HashCode()" function. Could someone explain what the method does (examples
might help).
Thanks
- Prashant
Mazeiar Salehie
2005-01-11 22:02:58 UTC
Permalink
Try to generate a unique number (which is called hash value) by a
combination of numerator and denominator. Of course there will be collisions
(not completely unique). As the hint in the hashCode() says, think large
prime numbers to define a hashcode.

Mazeiar Salehie
Post by prashant
I was having problem understanding the method requirements for "int
HashCode()" function. Could someone explain what the method does (examples
might help).
Thanks
- Prashant
Douglas Harder
2005-01-15 07:15:36 UTC
Permalink
Just one warning: you must implement the functions exactly as described in
the document. The signature of the function must be int hashCode(), not int
HashCode().

I discussed this method in detail with the comp class, and I will discuss it
with the elecs on Monday.

Douglas
Post by prashant
I was having problem understanding the method requirements for "int
HashCode()" function. Could someone explain what the method does (examples
might help).
Thanks
- Prashant
Loading...