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
I received this question during an interview, the question is Given two integers, return the number of digits that they share. For example 129 and 431 would return 1 - as they both share the digit 1, but no other digit. 95 and 780 would return 0, sin
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
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,
I'm studying on hash table with chaining in java by its implementation. The trouble is about get() method. An index value is determined with key.hashCode() % table.length. Assume that the table size is 10 and key.hashCode() is 124 so index is found a
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
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
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
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
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
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
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
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
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
EDIT: I really appreciate everyone's input. I gained something from all the responses and learned a good deal about OOD. I am making a simple virtual tabletop war game. To represent units on the battlefield I have the following simple class hierarchy
I have an std::unordered_map that I will be removing elements from via iteration. auto itr = myMap.begin(); while (itr != myMap.end()) { if (/* removal condition */) { itr = myMap.erase(itr); } else { ++itr; } } I would like to prevent the map for pe
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
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
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
From the link below, I know Java uses (hash & 0x7FFFFFFF) % tab.length to decide which slot of an array to put the {key, value} in. http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/util/Hashtable.java#Hashtable.put%2
I want to store a lua table where the keys are other lua tables. I know that this is possible BUT I want to be able to do look ups in the table using copies of those tables. Specifically, I want to be able to do: t = {} key = { a = "a" } t[key]
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
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
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(
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
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
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 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
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
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