Nested Sequence Hash Bug

new topic     » topic index » view thread      » older message » newer message

The following keys all have minor differences. But they all hash to the same value with HSIEH30 which is extremely unusual. Is this a hash bug or my misunderstanding? Thanks.

include std/hash.e 
 
sequence key1 = {{{},3},{{{{1,1,4},{2,0,5},1},{{3,1,4},{2,0,5},1},{{2,1,4},{2,0,5},1},{{5,1,4},{2,0,5},1},{ 
{4,1,4},{2,0,5},1},{{6,1,4},{2,0,5},1}},3},{{},3},{},{{},3},{{},3},6} 
 
sequence key2 = {{{},3},{{{{1,1,4},{2,0,5},1},{{3,1,4},{2,0,5},1},{{2,1,4},{2,0,5},1},{{5,1,4},{2,0,5},1},{ 
{6,1,4},{2,0,5},1},{{4,1,4},{2,0,5},1}},3},{{},3},{},{{},3},{{},3},6} 
 
sequence key3 = {{{},3},{{{{4,1,4},{2,0,5},1},{{5,1,4},{2,0,5},1},{{3,1,4},{2,0,5},1},{{2,1,4},{2,0,5},1},{ 
{6,1,4},{2,0,5},1},{{1,1,4},{2,0,5},1}},3},{{},3},{},{{},3},{{},3},6} 
 
sequence key4 = {{{},3},{{{{1,1,4},{2,0,5},1},{{3,1,4},{2,0,5},1},{{2,1,4},{2,0,5},1},{{6,1,4},{2,0,5},1},{ 
{5,1,4},{2,0,5},1},{{4,1,4},{2,0,5},1}},3},{{},3},{},{{},3},{{},3},6} 
 
sequence key5 = {{{},3},{{{{1,1,4},{2,0,5},1},{{4,1,4},{2,0,5},1},{{5,1,4},{2,0,5},1},{{3,1,4},{2,0,5},1},{ 
{2,1,4},{2,0,5},1},{{6,1,4},{2,0,5},1}},3},{{},3},{},{{},3},{{},3},6} 
 
printf(1, "Why are these all 202008777?\n") 
 
? hash(key1, HSIEH30) 
? hash(key2, HSIEH30) 
? hash(key3, HSIEH30) 
? hash(key4, HSIEH30) 
? hash(key5, HSIEH30) 
 
printf(1, "0 is a better algorithm:\n") 
 
? hash(key1, 0) 
? hash(key2, 0) 
? hash(key3, 0) 
? hash(key4, 0) 
? hash(key5, 0) 

Output

Why are these all 202008777? 
202008777 
202008777 
202008777 
202008777 
202008777 
0 is a better algorithm: 
4288307168 
3098639727 
939899006 
1488901913 
1623105407 

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu