ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

I don't know if there's any way to guarantee that two words won't hash to the same value, but you can make it pretty unlikely by choosing a hash function that's pretty well spread out, and making sure you have a workaround in case you do get a duplicate hash (such as choosing the next value in sequence or whatever - not sure what you're planning to do with this).

Anyhow, a google search for 'hash functions' will give you plenty of material to look at.

Given that a word can be up to 69 characters long, the number of possible words is greater than 26^69, so there's no way to build a function which given a word will return a 8 byte (or less) value unique to that word.

For hashing function, there are many algorithms which try to produce very well distributed output, but your program would probably work fine with something lazy like adding the ascii values of all the characters in the word together. (I'm sure this is a horrible way to hash ascii text, but my point is that it probably won't be noticeable ) The typical way to use this is to have linked lists for each group of words which hash to the same value. The lists will be pretty short.