A hash table is a data structure used to implement an associative array (a structure that can map keys to values). It uses a "hash function" to compute an index into an array from which the value can be found.
0
votes
1answer
15 views
Hashing with linear probing
I am seeking a review of a previous project I completed to help understand hash tables. The following is my implementation of a hash-table using linear probing.
My solution assumes a number of ...
-2
votes
2answers
65 views
Two-letter word dictionary - array index implementation
Here is the code for a two-letter word dictionary (example: aa) using array indexing:
...
0
votes
1answer
29 views
Quadratic probing and hashing - search for words in text files
I created a program for a college class. After I got it working, I wanted to improve it. As a beginner, it is probably a mess.
Description
It uses a HashFunction ...
3
votes
1answer
37 views
Hash table using linear probing
This code is meant to implement a hash table class which uses linear probing.
I'm doing this to improve my style and to improve my knowledge of fundamental algorithms/data structures for an upcoming ...
1
vote
0answers
18 views
Project Euler - #5 smallest multiple [Ruby using a hash table]
Why will this code will work for a smaller multiple like 10 but time out for anything over 13?
Can this code be refactored to work for larger numbers?
(p.s. I have an alternate solution but wanted ...
3
votes
1answer
46 views
3
votes
2answers
72 views
Kattis Issue - Animal Classifcation #2
Due to severe code-evolution i will repost this question here! The original can be found here : Kattis Challenge - Animal Classification
I'm new to competitive programming and C++ in general. I ...
3
votes
1answer
25 views
A set of functions that supports a spell checker
This is a program that loads a dictionary into a hash-table, and spell checks a text file provided as a command-line argument. The dictionary is formatted as such (just alphabetically):
...
0
votes
1answer
28 views
Optimize hash OCaml
I am running a simple OCaml program which opens a CSV file with a pseudo dict-reader and hashes "key" + "value" (where key and values are strings). Then some counts are evaluated on the hashes (but it ...
2
votes
2answers
88 views
Remove a key from list of hashes
Suppose my milestone is this:
milestones = [ {state: 'unavailable'}, {state: 'arrived'}, {state: 'completed'} ]
I want to remove all the ...
2
votes
3answers
64 views
Optimizing Java SHA-512 String-to-Hash Generator
In an attempt to learn Java and SHA-2 I created a very simple String-to-SHA512 generator. Here is the code:
...
3
votes
1answer
63 views
Merging hashes, summing values that have the same key
I'm trying to group by keys in an Array of Hashes in the following form and add their totals. Maybe with #map and #reduce/#inject. I know there is a more compact way to do this.
Given I have
...
2
votes
3answers
359 views
Simple Chaining Implementation of HashMap
I'm practicing writing my own simple version of a Java HashMap. I don't have much experience with generics in Java.
...
6
votes
1answer
86 views
Calculating protein mass
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see A sequence of mistakes. The repository with all my up-to-date solutions so far can be ...
1
vote
0answers
67 views
custom hash table<K,T> that take responsibility to assign hashcode/index
Introduction
I try to create a game engine with component-based architecture.
There are many type game components and different game systems.
For example, the components can be
Com_HP (health), ...
3
votes
1answer
78 views
Implementing clearTable, grow and shrink on a hash table
I've gone through previous questions about implementing hash tables in python, but I have something little more specific. I am handling collisions with linear probing, and I want to grow/shrink my ...
8
votes
2answers
183 views
Hash table OOP implementation in C
To brush up my C I decided to do some OOP programming in C. I have never tested this before, but I was curious to try it since seeing an example of it a while ago. I decided to implement a simple hash ...
1
vote
1answer
185 views
Merging two hashes with the mean values of each key if both hashes exist
There are two methods, hash1 and hash2, that return hashes or nil. The hashes have the same ...
1
vote
2answers
350 views
Merge array of hashes, keeping duplicate values as arrays
I am working on a Ruby gem to pull data from the Wikidata API. The data is deeply nested, as it contains a lot of repetition.
I have written a piece of Ruby (sans Rails) code that enables an array ...
4
votes
2answers
94 views
Is this the right way to implement a simple hash table in C++?
Does this look like a proper implementation of a hash table in C++? Any errors anyone can find?
Thanks in advance (:
...
1
vote
0answers
181 views
Implementing a HashTable in Objective-C
I am trying to implement a hash table in Objective-C. I did some testing and the implementation seems to work. I am using an NSMutableArray to store linked lists ...
9
votes
3answers
2k views
Simple C# HashTable Implementation
Haven't put one of these together since college. How does this look overall?
...
5
votes
1answer
58 views
2
votes
1answer
61 views
Displaying a String array in tabular format
I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular ...
0
votes
1answer
43 views
NestedHash Class
I want to make a Ruby nested hash table class to avoid repeating ugly code and to keep my programs as true to the OOP paradigm as I can. Are there any ways to make this class definition smaller and/...
1
vote
1answer
122 views
Creating a dictionary
I have a Ruby programming task. My code passes all the rspec requirements, but I am not sure if I've done it in the right way. And I'm not quite sure why I need ...
2
votes
1answer
66 views
5
votes
4answers
3k views
Python Hash Table Implementation
I'm attempting to implement a basic hash table in Python using only lists. Any tips would be appreciated (including better hash functions).
I intend this to handle collisions with separate chaining.
...
2
votes
1answer
2k views
Convert Multivalued map to HashMap
I have a Multivalued map (javax.ws.rs.core.MultivaluedMap<String, String>) which I want to convert to regular HashMap so I got below code:
...
3
votes
1answer
265 views
Hackerrank challenge - Dictionaries and Maps in Erlang
This question is really similar to an existing one in Ruby. So the task is also the same: Day 8: Dictionaries and Maps!
The problem is that on Hackerrank my solution only passes the first and last ...
-3
votes
1answer
562 views
Mapping phone numbers to names [closed]
Problem description:
You are given a phone book that consists of your friend's names and
their phone number. After that you will be given your friend's name
as query. For each query, print the ...
5
votes
2answers
817 views
Hackerrank challenge - Dictionaries and Maps
This is a solution for the Day 8 hackerrank.com challenge. The basic idea of the challenge is to create a mapping of names to phone numbers based on the the given input, and later look up the phone ...
0
votes
2answers
60 views
Adding polynomials represented as maps
I'm using maps to represent a polynomial.
The key is the exponent and the value is the coefficient : Map(exp -> coef)
e.g. ...
5
votes
2answers
49 views
Refactoring if statement based on a hash key
I have to call Article.to_draft/to_archive/publish method depending on the presence of the ...
4
votes
2answers
420 views
Dictionary implementation using hash table in C
I have written the below code which loads the dictionary and checks if the given word is present or not.
The implementation is using a hash table with a chained linked list.
In regards to the hash ...
3
votes
2answers
609 views
HashMap or associative arrays in C
I am trying to implement an HashMap in C. I am trying to used a linked list style of interfacing to make adding and removing keys easy and efficient. Searching is ...
5
votes
0answers
23 views
Variation of the internal PHP hashtable
I'm working on a PHP extension in an attempt to learn some C. I've implemented a variation of the internal PHP hashtable, which uses a lookup table and a separate bucket table. The lookup table simply ...
6
votes
2answers
84 views
Unicode-capable symbol table (N-way search tree with hash buckets)
As in my previous question, this module is coupled with its own testing framework.
As a symbol-table for a Unicode-capable programming language interpreter, I decided to combine the 3 types of ...
6
votes
4answers
1k views
Hash table and linked list implementation in C++
I'm trying to improve my understanding of inheritance and template classes in C++ so I coded a hash table (see compilable source code below).
I would be greatly appreciative of any comments on how to ...
6
votes
1answer
232 views
Remove a key from a hash table efficiently
I am trying to remove a key from a hash table, which is built using linear probing. Removing a key works fine but I know I need to rehash a portion of the table after the removal but my method down ...
7
votes
2answers
488 views
Trie key/value store implementation comparing with HashMap
I have implemented a Trie-based concurrent key/value store using hashcode similar to HashMap.
It is something like, if your ...
3
votes
1answer
1k views
Hash function for strings
Implementation of a hash function in java, haven't got round to dealing with collisions yet.
I tried to use good code, refactored, descriptive variable names, nice syntax.
My code must be efficient ...
1
vote
1answer
390 views
Hash Map Library for any type (Void Pointers)
This is a hash map library for C that stores void* pointers with char* strings (null terminated) for keys
...
10
votes
1answer
117 views
ConcurrentDecayingHashMap<K,V>, a concurrent decaying HashMap
I wrote a wrapper for Java's ConcurrentHashMap that enables you to add a decay time to inserted values, meaning they will be automatically removed after the given ...
3
votes
2answers
315 views
Using EqualityComparer to find contained value
While searching for a method in HashSet which allows me to actually find an object in \$O(1)\$ (not just Contains, I need the ...
4
votes
1answer
35 views
Optimizing “complex” iteration over Map with auxiliary maps
This will be tough to explain. I am implementing a tool to support RFC6020. But when it comes to the Choice Statement, things get weird.
For the sake of better understanding, I have to remember you a ...
4
votes
0answers
262 views
HashMap and HashSet classes for ES6
The new EcmaScript standard, ES6, contains specifications for Map and Set built-in classes. Each of these collections treats an ...
3
votes
1answer
63 views
Creating simulated items sold at a store into a hash
I am writing code that creates a hash for a store that has an item, price, and sku. The hash is inserted into an array. I also create another hash based on the sku that holds the amount of inventory ...
1
vote
1answer
71 views
Gathering metadata on files in GitHub
I am a relatively new programmer and am currently working on something with the egit GitHub client library which requires me to iterate over a bunch of values and if a condition is met, add a bunch of ...
3
votes
1answer
94 views
Constructing NewsArticle objects from a database table
This class seems to be able to represent the data stored in any possible database table:
...