Store groups of words in hashtable

I have an ArrayList of words, and I want to compare the words against each other, to store them in a HashTable (in groups of anagrams). I know how to compare two words to test if they are an anagram, but I can't figure out how to compare a longer lis

Linear hash table survey data structure

When using linear probing, why can't a load factor threshold of 1.1 be chose for a hash table? Is that supposed to work for all the numbers?I'm not sure why I forgot this, but thanks to izaak_pyzaak for reminding me. If you're using linear probing, I

Realloc Error: realloc (): invalid next size

I coundn't find a solution for the problem below. I have searched for this too many times, but I still don't know how to solve. What I have to do: I have to make a program that reads an archive with random tweets and saves it in a matrix. After that,

PowerShell splatting merging into a hashtable

This code does what I want it to do: $EventParams = @{ LogName = $LogName Source = $Source } $EventInfoParams = $EventParams + @{ EntryType = 'Information' EventID = '0' } $EventWarnParams = $EventParams + @{ EntryType = 'Warning' EventID = '1' } $Ev

Data Structure Project Ideas?

Firstly this question maybe a little bit broad, if so, is there any stackoverflow related site where this question would not get marked as broad? Anyway I have a project and for that project I need to use data structure(s). I am unable to think of an

get the value of the hash

Ticket* Championship::findTicketByFanID(unsigned int id) { hTabTickets::iterator it = tickets.begin(); while(it != tickets.end()) { if(it->getOwnerID() == id) return it; } } Hello there I'd like to return the object that is on iterator it. tickets is

In java, what happens when removing an object during its use?

Here is the scenario: I have a java Hashtable that takes a String as a key and an object as the value. One thread gets the object by using the key and calls a method on this object. while the method is doing some operation from step b), another threa

How to convert a string to a hash key

I need to convert a string (max. length = 20, consisting of random lower alphabetical characters and/or numbers) to a key for a hash table that holds slots for a max of 100.000 keys. What I tried is to convert each of the chars within the string to a

Fastest hash function possible / search for a primitive key

My application needs to do a lookup in a data set potentially several million times per second. (HPC related) It is a very specific use case where the following is true: The data set has a fixed set of entries. It never shrinks, nor grows. The key is

Ruby Array group_by key with multiple values

I have a Ruby Array: [ {tags: [1,2]}, {tags: [1,3]}, {tags: [1,4]}, {tags: [2,4]}, {tags: [2,5]} ] I need to group the objects by their tags: { 1: [{tags: [1,2]}, {tags: [1,3]}, {tags: [1,4]}], 2: [{tags: [1,2]}, {tags: [2,4]}, {tags: [2,5]}], 3: [{t

What is the complexity of the time in the chained hash table

I've a hashtable which consists of 1000 elements and 100 buckets with maximum 100 entries per bucket. Suppose one bucket has 100 entries (i.e. 100 items in the list of that bucket). Now what will be the time complexity in terms of big-O notation if t

Handling the Key Collision in Hashmap

The code I found for Hashmap's put(K key, V value). This method replaces the value if collision occured, it doesn't add the Entry to the LinkedList of the bucket. What I am missing here?Why do you think? The relevant lines are as follows: Calculate i

Java based chat application Hashtable

I am using Hashtable for a http chat application using google app engine. I get strange behavior from Hashtable. Sometime it return null when i try to look for an id by using Hashtable.get(id) method. I need your help that is Hastable good for such c

Variable size cache LRU

I am trying to implement an LRU cache in Java which should be able to: Change size dynamically. In the sense that I plan to have it as SoftReference subscribed to a ReferenceQueue. So depending upon the memory consumption, the cache size will vary. I

Perl: Divide a hash into several according to its keys?

Let's say that I have a hashref whose Data::Dumper output looks like this: $VAR1 = { foo_0 => 'foo_zero', foo_1 => 'foo_one', bar_0 => 'bar_zero', bar_1 => 'bar_one' } I would like to split this hash into two based on its keys as shown below b

Hashtable with doubly linked lists?

Introduction to Algorithms (CLRS) states that a hash table using doubly linked lists is able to delete items more quickly than one with singly linked lists. Can anybody tell me what is the advantage of using doubly linked lists instead of single link

Tips on chopping tables in C language

I need some ideas to develop a good hashing function for my assignment. I have a list of all the countries in the world (around 190) in total. The names of each country is the key for the hashing function. Is there a specific kind of hashing function

Hashing used by Hashtable?

What kind of hashing methodoly is used in Hashtable implementation in Java?In Java the Object class defines a method int hashCode(). Each class implements this differently, or not at all. The default implementation is to call System.identityHashCode(

compare the pairs stored in hashtable java

at first i have a 2d array storing many numbers and then i used an array of hushtables to store pairs formed by the numbers of each row of the 2d array. for example in the first row of the 2d array, the numbers are 1 2 3 4 5 then the pairs should be

On-site dictionary inversion in Python

I need to invert a dictionary of lists, I don't know how to explain it in English exactly, so here is some code that does what I want. It just takes too much memory. def invert(oldDict): invertedDict = {} for key,valuelist in oldDict.iteritems(): for

C ++ hash table without using STL

I need to create a hash table that has a key as a string, and value as an int. I cannot use STL containers on my target. Is there a suitable hash table class for this purpose?Here's a quick a dirty C hash I just wrote. Compiles, but untested locally.

Why is the table attribute of Hashtable serialized?

Why is the table field of Hashtable serialized, although it is marked as transient?It is marked as transient because it is unsafe to use the default serialization scheme on the Entry array. Rather, when a Hashtable is deserialized, the keys in the ta

Sorting a hash table based on its input value (not the key)

I want to get the following code to work in the Java ME / J2ME environment. Please help: Hashtable <Activity, Float>scores = new Hashtable<Activity, Float>(); scores.put(act1, 0.3); scores.put(act2, 0.5); scores.put(act3, 0.4); scores.put(act5

Update cached data in a hash table

In order to minimize the number of database queries I need some sort of cache to store pairs of data. My approach now is a hashtable (with Strings as keys, Integers as value). But I want to be able to detect updates in the database and replace the va