akdom / hash-thingy Goto Github PK
View Code? Open in Web Editor NEWCSC316 Project 2
CSC316 Project 2
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 | +---------+---------+----------+
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.