Git Product home page Git Product logo

hash-thingy's Introduction

hash.c - created by Alex Kesling (ahkeslin), Samuel Christie (schrist)

Compilation:

Run the following command to compile hash.c to hash.out
  # make

Execution requires first argument be input file
  # ./hash.out <input_file>

Hash function:

We used a simple combination of shift, add and xor operations to hash our keys:

	for (i=0; i < length; i++) {
		hash ^= (hash<<7) + (hash>>5) + our_vec[i];
		hash += 1;
	}

This function was chosen because of its simplicity and effectiveness. It isn't especially good, but none of our attempts at improvement or alternatives resulted in much improvement.  We found something incredibly similar to this online (lost the source...) and it inspired our use.  In all honesty, we really just fiddled with different hash  operations and settled on this, since it gave the best results for the largest data set.  The ^= mixes in each of the vector components in such a way that it is significantly different for the same components in a different order.  The "(hash<<7) + (hash>>5)" also ensures ordering has a significant effect on the resulting hash.  The "hash += 1" just kind of makes it a little better... for no apparent reason.

Collision policy:

We used the simple policy of creating a linked list of nodes with the same hash code. This method guarantees a low amount of probing required, a low memory overhead, and reasonable lookup times. In our testing the longest linked list was about 8 elements long.

It performed as we expected; no unnecessary complexity and acceptable speed.

Performance Table:

+---------+---------+----------+
|Dataset  |Time (s) |Space (MB)|
+---------+---------+----------+
|ncd1     |0.016971 |0.126663  |
+---------+---------+----------+
|ncd2     |0.003566 |0.135796  |
+---------+---------+----------+
|ncd3     |0.027530 |0.186779  |
+---------+---------+----------+
|ncd4     |0.054958 |0.313293  |
+---------+---------+----------+
|multiklas|0.017517 |0.239788  |
+---------+---------+----------+
|sat10    |0.001361 |0.129135  |
+---------+---------+----------+
|sat100   |0.016979 |0.158798  |
+---------+---------+----------+
|sat1000  |0.064977 |0.324234  |
+---------+---------+----------+
|sat10000 |0.354840 |1.367477  |
+---------+---------+----------+
|Average  |0.0620777|0.331329  |
+---------+---------+----------+

hash-thingy's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.