CS6515 EXAM 2 FINAL PAPER 2026
QUESTIONS WITH ANSWERS GRADED A+
⩥ average case for a string table. Answer: The average case is Theta 1
because the running time for the average case is dependent on the load
factor, which in this case is assumed to be constant
⩥ code for adding the string table into the cloud. Answer: do one for
loop going thru the indexes of the array, then for each loop going thru
each record in b[i]. then call insert for other record but use the new
number of buckets for to index
⩥ run time to get everything from a table into a cloud. Answer: The
running time would be Theta n because under the assumption of simple
uniform hashing, the elements are evenly distributed so there would be
an even distribution among each list. This means the length of the lists
are insignificant in comparison to the total number of elements, so the
find method would take constant time (and therefore insert and remove
are also constant because they use find). But, we call the insert n times
for the n number of elements to be inserted into the table, so the running
time would be n.
⩥ when to allocate a new table for the cloud. Answer: We would allocate
a new table once the load factor becomes greater than L.
,⩥ size of the table when it runs out of space in cloud. Answer: double
the size
⩥ purpose of hashcode generation. Answer: -map integers in some range
-object that are equal() must have the same hashcode
-objects that are notEqual() should have distinct hashcodes (but this
might not be possible bc of pigeonhole principle)
⩥ should hash codes be spread uniformly across range w/o obvious
correlations?. Answer: 2 arguments:
-no 2nd step (index generation) is responsible for ensuring unequal hash
codes mapped to uniform uncorrelated indices
-yes index generator is not responsible for fixing bad hashcode
generator. even if index generator scrambles hashcode, if universe is
much greater than # of possible hashcodes, there is a greater likelihood
that the objects map to the same hashcode. gonna have collisions so
bucket might not help
⩥ hashcodes for 32 bit integers. Answer: use unchanged
⩥ 32 bit floating point. Answer: use underlying bits as integer
(floatToIntBits())
, ⩥ 64 bit long. Answer: hashcode = [value XOR (value / 2^32) ] mod
2^32
if we want uniformity use multiplicative hashing w m = 2^32
⩥ hashcodes for types with limited # of values. Answer: booleans,
enums
cannot hope to cover entire space of hashcodes. so either map to small
ints (true = 0 and false = 1) rely on index calc scramble
OR
guess a mapping with nice properties. true = 1231 and false = 1237 bc
these #s are prime #s, not small and not next to each other
⩥ hash composite objects. Answer: either sets or sequences
⩥ sets. Answer: collection of objects that have no order [Java Set]
{3,2,5} = {2,5,3} = {5,3,2}
{} these denote sets
QUESTIONS WITH ANSWERS GRADED A+
⩥ average case for a string table. Answer: The average case is Theta 1
because the running time for the average case is dependent on the load
factor, which in this case is assumed to be constant
⩥ code for adding the string table into the cloud. Answer: do one for
loop going thru the indexes of the array, then for each loop going thru
each record in b[i]. then call insert for other record but use the new
number of buckets for to index
⩥ run time to get everything from a table into a cloud. Answer: The
running time would be Theta n because under the assumption of simple
uniform hashing, the elements are evenly distributed so there would be
an even distribution among each list. This means the length of the lists
are insignificant in comparison to the total number of elements, so the
find method would take constant time (and therefore insert and remove
are also constant because they use find). But, we call the insert n times
for the n number of elements to be inserted into the table, so the running
time would be n.
⩥ when to allocate a new table for the cloud. Answer: We would allocate
a new table once the load factor becomes greater than L.
,⩥ size of the table when it runs out of space in cloud. Answer: double
the size
⩥ purpose of hashcode generation. Answer: -map integers in some range
-object that are equal() must have the same hashcode
-objects that are notEqual() should have distinct hashcodes (but this
might not be possible bc of pigeonhole principle)
⩥ should hash codes be spread uniformly across range w/o obvious
correlations?. Answer: 2 arguments:
-no 2nd step (index generation) is responsible for ensuring unequal hash
codes mapped to uniform uncorrelated indices
-yes index generator is not responsible for fixing bad hashcode
generator. even if index generator scrambles hashcode, if universe is
much greater than # of possible hashcodes, there is a greater likelihood
that the objects map to the same hashcode. gonna have collisions so
bucket might not help
⩥ hashcodes for 32 bit integers. Answer: use unchanged
⩥ 32 bit floating point. Answer: use underlying bits as integer
(floatToIntBits())
, ⩥ 64 bit long. Answer: hashcode = [value XOR (value / 2^32) ] mod
2^32
if we want uniformity use multiplicative hashing w m = 2^32
⩥ hashcodes for types with limited # of values. Answer: booleans,
enums
cannot hope to cover entire space of hashcodes. so either map to small
ints (true = 0 and false = 1) rely on index calc scramble
OR
guess a mapping with nice properties. true = 1231 and false = 1237 bc
these #s are prime #s, not small and not next to each other
⩥ hash composite objects. Answer: either sets or sequences
⩥ sets. Answer: collection of objects that have no order [Java Set]
{3,2,5} = {2,5,3} = {5,3,2}
{} these denote sets