<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-5%3Amabd065</id>
	<title>SE250:lab-5:mabd065 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-5%3Amabd065"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-5:mabd065&amp;action=history"/>
	<updated>2026-04-28T14:49:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-5:mabd065&amp;diff=6662&amp;oldid=prev</id>
		<title>Mark: 12 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-5:mabd065&amp;diff=6662&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:51Z</updated>

		<summary type="html">&lt;p&gt;12 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;I was kind of shocked looking at the code to start with. But after having a look at some parts of the code and seeking help from the tutor (although it wasn&amp;#039;t that great help), i managed to get an idea of what i am supposed to do.&lt;br /&gt;
&lt;br /&gt;
I managed to compile quickly using the *.c command which was mentioned in the lab sheet. This was very helpful.&lt;br /&gt;
&lt;br /&gt;
I managed to compile all of the code required for Part 1 in one shot. But had no clue to the actual meaning of the results at the beginning. After seeking the help of the lecturer (which was really helpful), i started making sense of the whole lab (even though an explanation of the meaning of the stats terminology before hand would have been way better and could have saved the lecturer a lot of time explaining it to students individually).&lt;br /&gt;
&lt;br /&gt;
The code for part 1 is as follows:&lt;br /&gt;
&lt;br /&gt;
CODE:&lt;br /&gt;
&lt;br /&gt;
 int main( ) {&lt;br /&gt;
   int sample_size = 100000;&lt;br /&gt;
   int n_keys = 1000;&lt;br /&gt;
   int table_size = 10000;&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;Buzhash low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_buzhash );&lt;br /&gt;
   ent_test( &amp;quot;Buzhash high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_buzhash );&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;buzhashn low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_hash_CRC );&lt;br /&gt;
   ent_test( &amp;quot;buzhashn high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_hash_CRC );&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;hash_CRC low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_hash_CRC );&lt;br /&gt;
   ent_test( &amp;quot;hash_CRC high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_hash_CRC );&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;base256 low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_base256 );&lt;br /&gt;
   ent_test( &amp;quot;base256 high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_base256 );&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;Java Int low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_Java_Integer );&lt;br /&gt;
   ent_test( &amp;quot;Java Int high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_Java_Integer );&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;Java Object low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_Java_Object );&lt;br /&gt;
   ent_test( &amp;quot;Java Objec high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_Java_Object ); &lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;Java String low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_Java_String );&lt;br /&gt;
   ent_test( &amp;quot;Java Strin high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_Java_String );&lt;br /&gt;
   &lt;br /&gt;
   ent_test( &amp;quot;Rand  low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_rand );&lt;br /&gt;
   ent_test( &amp;quot;Rand  high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_rand );&lt;br /&gt;
 &lt;br /&gt;
   ent_test( &amp;quot;high rand low&amp;quot;, low_entropy_src, sample_size, &amp;amp;rt_add_high_rand );&lt;br /&gt;
   ent_test( &amp;quot;high rand high&amp;quot;, typical_entropy_src, sample_size, &amp;amp;rt_add_high_rand );&lt;br /&gt;
  &lt;br /&gt;
   return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=======================&lt;br /&gt;
&lt;br /&gt;
The results were:&lt;br /&gt;
------------------&lt;br /&gt;
&lt;br /&gt;
 For:&lt;br /&gt;
   int sample_size = 100000;&lt;br /&gt;
   int n_keys = 1000;&lt;br /&gt;
   int table_size = 10000;&lt;br /&gt;
 &lt;br /&gt;
 		&lt;br /&gt;
 Buzhash low	7.99830	75.00%	127.578	0.71%	0.000327 &lt;br /&gt;
 Buzhash high	7.99783	2.50%	127.374	0.77%	-0.000076&lt;br /&gt;
 buzhashn low	5.59831	0.01%	81.783	24.53%	0.028545 &lt;br /&gt;
 buzhashn high	7.84046	0.01%	122.862	1.98%	0.018518&lt;br /&gt;
 hash_CRC low	5.71827	0.01%	112.143	12.43%	-0.204906&lt;br /&gt;
 hash_CRC high	7.84046	0.01%	122.862	1.98%	0.018518 &lt;br /&gt;
 base256 low	0.00000	0.01%	97.000	27.32%	undefined&lt;br /&gt;
 base256 high	4.02297	0.01%	107.853	27.32%	0.034082&lt;br /&gt;
 Java Int low	4.82824	0.01%	43.883	27.32%	-0.092002&lt;br /&gt;
 Java Int high	4.82824	0.01%	43.883	27.32%	-0.092002&lt;br /&gt;
 Java Object low	2.00000	0.01%	77.000	27.32%	-0.521556&lt;br /&gt;
 Java Objec high	5.72621	0.01%	118.129	4.28%	-0.343281&lt;br /&gt;
 Java String low	7.99958	99.99%	127.474	0.15%	0.001097&lt;br /&gt;
 Java Strin high	7.94554	0.01%	126.139	0.27%	0.021181 &lt;br /&gt;
 Rand  low	7.95308	0.01%	111.441	11.17%	-0.051837 &lt;br /&gt;
 Rand  high	7.95272	0.01%	111.395	10.65%	-0.049131&lt;br /&gt;
 high rand low	7.99828	75.00%	127.441	0.75%	-0.001213&lt;br /&gt;
 high rand high	7.99807	50.00%	127.406	0.07%	-0.002226&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
I used a sample size of 100000 because i though you wouldn&amp;#039;t really use a hash table for a small number of values. What i tought is that because we wanted to have the hash function as fast as possible, this implied to me that we have a large number of values. 100 000 seem large enough for me.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rearranging results:&lt;br /&gt;
&lt;br /&gt;
Using excel, i was able to arrange the results quickly by sorting the columns as shown above each column below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 		DESC*	DESC*	DESC*	ASC*	ASC*&lt;br /&gt;
 Buzhash low	7.9983	75.00%	127.578	0.71%	0.000327&lt;br /&gt;
 high rand low	7.99828	75.00%	127.441	0.75%	-0.001213&lt;br /&gt;
 high rand high	7.99807	50.00%	127.406	0.07%	-0.002226&lt;br /&gt;
 Java String low	7.99958	99.99%	127.474	0.15%	0.001097 &lt;br /&gt;
 Buzhash high	7.99783	2.50%	127.374	0.77%	-0.000076&lt;br /&gt;
 Java Strin high	7.94554	0.01%	126.139	0.27%	0.021181 &lt;br /&gt;
 buzhashn high	7.84046	0.01%	122.862	1.98%	0.018518&lt;br /&gt;
 hash_CRC high	7.84046	0.01%	122.862	1.98%	0.018518 &lt;br /&gt;
 Rand  low	7.95308	0.01%	111.441	11.17%	-0.051837&lt;br /&gt;
 Rand  high	7.95272	0.01%	111.395	10.65%	-0.049131&lt;br /&gt;
 base256 high	4.02297	0.01%	107.853	27.32%	0.034082&lt;br /&gt;
 Java Objec high	5.72621	0.01%	118.129	4.28%	-0.343281&lt;br /&gt;
 hash_CRC low	5.71827	0.01%	112.143	12.43%	-0.204906&lt;br /&gt;
 buzhashn low	5.59831	0.01%	81.783	24.53%	0.028545&lt;br /&gt;
 Java Int low	4.82824	0.01%	43.883	27.32%	-0.092002&lt;br /&gt;
 Java Int high	4.82824	0.01%	43.883	27.32%	-0.092002&lt;br /&gt;
 Java Object low	2	0.01%	77	27.32%	-0.521556 &lt;br /&gt;
 base256 low	0	0.01%	97	27.32%	undefined&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* * After what i have understood form the lecturer, sorting the results by column didn&amp;#039;t really give the desired outcome of showing the best functions at the top because with some tests, the function would rank well and for the other tests would rank below some really bad functions. For example, looking at the first set of results, base256 low would rank better for the mean test (97) compared to (81) buzhashn low.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A load factor of 10 might have been higher than the normal factors used. But that is what i have assumed to be a good factor.&lt;br /&gt;
&lt;br /&gt;
Part 2:&lt;br /&gt;
&lt;br /&gt;
Running the code:&lt;br /&gt;
==========================&lt;br /&gt;
 int main( ) {&lt;br /&gt;
   int sample_size = 100000;&lt;br /&gt;
   int n_keys = 10000;&lt;br /&gt;
   int table_size = 1000;&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;Buzhash low %d/%d: llps = %d, expecting %g\n&amp;quot;, n_keys, table_size,&lt;br /&gt;
   llps( n_keys, low_entropy_src, table_size, buzhash), expected_llps(n_keys, table_size));&lt;br /&gt;
   printf(&amp;quot;Buzhash high %d/%d: llps = %d, expecting %g\n&amp;quot;, n_keys, table_size,&lt;br /&gt;
   llps( n_keys, typical_entropy_src, table_size, buzhash), expected_llps(n_keys, table_size));&lt;br /&gt;
 &lt;br /&gt;
   printf(&amp;quot;Hash CRC low %d/%d: llps = %d, expecting %g\n&amp;quot;, n_keys, table_size,&lt;br /&gt;
   llps( n_keys, low_entropy_src, table_size, hash_CRC), expected_llps(n_keys, table_size));&lt;br /&gt;
   printf(&amp;quot;Hash CRC high %d/%d: llps = %d, expecting %g\n&amp;quot;, n_keys, table_size,&lt;br /&gt;
   llps( n_keys, typical_entropy_src, table_size,  hash_CRC), expected_llps(n_keys, table_size)); &lt;br /&gt;
 &lt;br /&gt;
   printf(&amp;quot;Base 256 low %d/%d: llps = %d, expecting %g\n&amp;quot;, n_keys, table_size,&lt;br /&gt;
   llps( n_keys, low_entropy_src, table_size, base256), expected_llps(n_keys, table_size));&lt;br /&gt;
   printf(&amp;quot;Base 256 high %d/%d: llps = %d, expecting %g\n&amp;quot;, n_keys, table_size,&lt;br /&gt;
   llps( n_keys, typical_entropy_src, table_size,  base256 ), expected_llps(n_keys, table_size));&lt;br /&gt;
 &lt;br /&gt;
  return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Gives:&lt;br /&gt;
&lt;br /&gt;
 Buzhash low 10000/1000: llps = 20, expecting 21.7096 &lt;br /&gt;
 Buzhash high 10000/1000: llps = 22, expecting 21.7096&lt;br /&gt;
 Hash CRC low 10000/1000: llps = 88, expecting 21.7096&lt;br /&gt;
 Hash CRC high 10000/1000: llps = 23, expecting 21.7096&lt;br /&gt;
 Base 256 low 10000/1000: llps = 10000, expecting 21.7096&lt;br /&gt;
 Base 256 high 10000/1000: llps = 497, expecting 21.7096&lt;br /&gt;
&lt;br /&gt;
 Rearranged from best to worst (ASCENDING order): &lt;br /&gt;
 Buzhash low 10000/1000: llps = 20, expecting 21.7096&lt;br /&gt;
 Buzhash high 10000/1000: llps = 22, expecting 21.7096&lt;br /&gt;
 Hash CRC high 10000/1000: llps = 23, expecting 21.7096&lt;br /&gt;
 Hash CRC low 10000/1000: llps = 88, expecting 21.7096&lt;br /&gt;
 Base 256 high 10000/1000: llps = 497, expecting 21.7096&lt;br /&gt;
 Base 256 low 10000/1000: llps = 10000, expecting 21.7096&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The results here match roughly what we expect in theory (results in part 1 of the experiment).&lt;br /&gt;
&lt;br /&gt;
The order of the best hash functions are ordered as follows:&lt;br /&gt;
 Buzhash&lt;br /&gt;
 Hash CRC&lt;br /&gt;
 Base 256&lt;br /&gt;
&lt;br /&gt;
Base256 is the worst of all! Feeding it with low or high amount of data gives results that are far from what we want. Although it performs relatively better with a higher source of data than a low one( 497 compared to 10000 ).&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>