<p>I read inBarron’s that you could make a hash table or something for quick organization and access to data. anyone knoow how to make one?</p>
<p>hash table?</p>
<p>You mean hashmap?</p>
<p>hash table: assign numerical values to nonnumerical data for storing in an array</p>
<p>dictionary hash (no spaces, i.e., “hot dog”):
count = 0
convert 1st letter to number (A=0, B=1, C=2, etc.) and add to count
multiply count by 26
repeat until you reach the end of the word</p>
<p>to convert back:
mod by 26 to retrieve last character
divide by 26 to delete last character
repeat</p>
<p>now, why should we do this? say we wanted to store a table of word histories. We could make an array of data structures containing a word and its history, but looking up a word would require an agonizing search (in this case binary search wouldn’t be too bad, but if you have to search for 100000 different words or something in a 1000000-word array, those “small” searches add up). Instead, we could just make a String array with (maxlength)^26 slots. Then when we enter in data, we hash the word and place the word history in the array at the index of the hash. Lookup is then simple: just hash the search word and see if anything is at that index.</p>
<p>The above example is brutally expensive in memory, so some hash tables would just, say, use the first 3 characters for the hash. Then, however, we get what is called a hash collision if both “car” and “card” appear in the data we want to store.</p>
<p>I have yet to take AP Comp Sci, so I’m not sure if this is correct…I just made the example off the top of my head, so it may or may not work, but I think it should work…</p>
<p>oops sorry…I meant (26)^(maxlength)</p>
<p>so a hash table isn’t like a class or method you call? </p>
<p>I don’t relaly understnad how your exampl works. but I’m slow so I’ll read it again</p>
<p>oh I am seeing it now. I don’t see how you actually store the words though ( like in a list, in a array, etc)</p>
<p>you don’t store the words; the words become the indices
ex. consider the dictionary entries
a, the first letter of the alphabet
e, the fifth letter of the alphabet
z, the last letter of the alphabet</p>
<p>String strArray = new String[26];
//code below would actually be done with an algorithm, not manually
strArray[0] = new String(“the first letter of the alphabet”);
strArray[4] = new String(“the fifth letter of the alphabet”);
strArray[25] = new String(“the last letter of the alphabet”);</p>
<p>there is a Hashtable class, but I’ll need to look up how it works (or you could just do it yourself by Googling it ;))</p>
<p>Yes, in a hashtable, you do sorta store your data. Here is the thing: basically each entry in the hashtable is a reference to an object. You also might want to look up linked-list implementations of hashtables(to prevent collisions) and infinite-dimensional hashmaps(hard to explain). Basically here is what it looks like:</p>
<p>0 - …
1 - …
2 - …
3 - …
4 - …
5 - …
6 - …
7 - …
8 - …
9 - …</p>
<p>so each thingy is a location in memory. Lets say you have 10 thingies. Basically, you are gonna use a hash function(usually a combination of the modulus operation, and prime numbers) to determine a hash-value. This hashvalue is the index of the particular object in the array. So if the object is the household, and you are given a phone number, you could run a hash-function on the phonenumber to give index of that household in the array. g2g, cut get some computer science books(really ones, that are at least 700 pages long) on data structures. Also, study pointer manipulation, since you are half blind if you don’t understand exactly how references work.</p>
<p>very easy</p>
<p>put the hash on your table.</p>
<p>Then there’s your hashtable</p>
<p>I wonder how HypnosX would explain a “binary tree”, “inheritance”, or “superclass” lol</p>