Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [hash-table]

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.

Filter by
Sorted by
Tagged with
3
votes
1answer
283 views

HashMap in Javascript

I began working on a Javascript project, and the first fundamental building block is a data structure that mimics Java's java.util.HashMap, since Javascript ...
4
votes
1answer
145 views

Spatial Hash for optimizing AABB collisions

grid.h ...
5
votes
1answer
960 views

LRU Cache Implementation with HashTable and LinkedList

Problem Statement: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be ...
3
votes
1answer
277 views

Half generic hash table

After alot of reading and testing I've created a "half generic" hash table. What I mean by half generic is that the struct that I'm using have a name variable which is ...
3
votes
4answers
3k views

C hashtable implementation

The following code is an implementation of an hashtable in C. hashTable.c: ...
4
votes
1answer
1k views

HashTable implementation using bucket lists

I wrote an implementation of a HashTable that uses bucket lists to store the key-value pairs implemented with a linked list. Here's the header: ...
6
votes
0answers
112 views

Bidirectional bijective hash map in C

I have this bidirectional hash map in C for dealing with bijective maps. Each key mapping consists of a primary key and a secondary key, and I can ask the data structure to give me a secondary key ...
8
votes
2answers
491 views

method to decide if two strings are anagrams

I'm studying with the Cracking the Code Interview book. I'm just looking for some feedback on this method: C++ ...
5
votes
2answers
3k views

Using GetHashCode in Equals

I have a scenario when I want to have a HashSet<ITrackableObjectData>, where ITrackableObjectData has ...
2
votes
2answers
534 views

Hash Table insertion linear probinig

My code is working fine Could you please review how I can make it more accurate and efficient? ...
-1
votes
1answer
274 views

Simple example of a hash table using square as key

I'm studying hash tables, and wrote the following to serve as a simple example. Does this properly demonstrate the basic concept of a hash table? The values are ...
1
vote
0answers
78 views

Fast HashIndex (HashTable) “template” for indexes and arrays C++

Another in the long line of data structures I'm writing for my 2D isometric game. This is a hashtable that only handles indexes, hence eHashIndex. It does not copy ...
1
vote
3answers
8k views

Resize the hash table and rehash every element

I'm trying to increase my hash table size by two if the table is filled more than half of it. I tried to rehash every single element from the old table and put it back to my new table, then assign my ...
1
vote
1answer
980 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
108 views

Two-letter word dictionary - array index implementation

Here is the code for a two-letter word dictionary (example: aa) using array indexing: ...
1
vote
1answer
146 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
4k 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 ...
0
votes
1answer
99 views

Project Euler - #5 smallest multiple (Ruby using a hash table)

Why will this code work for a smaller multiple like 10 but time out for anything over 13? Can this code be revised to work for larger numbers? (I have an alternate solution but wanted to see if this ...
2
votes
1answer
855 views

Hash table using open addressing with double hashing probing

Looking for a general review: ...
3
votes
2answers
151 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
50 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): ...
1
vote
1answer
168 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
107 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 ...
3
votes
4answers
2k 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: ...
4
votes
1answer
3k 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 ...
3
votes
3answers
3k 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. ...
8
votes
1answer
206 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
87 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
1k 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
735 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
4k 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 ...
2
votes
2answers
6k 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
177 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 (: ...
2
votes
1answer
1k 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 ...
12
votes
3answers
11k views

Simple C# HashTable Implementation

Haven't put one of these together since college. How does this look overall? ...
5
votes
1answer
68 views
2
votes
1answer
2k 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
46 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
382 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
131 views

Basic toy hashtable

I wrote a minimal implementation of a hashtable in python as an exercise. ...
10
votes
5answers
19k 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
15k 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
2answers
566 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
2k 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 ...
6
votes
2answers
1k 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
89 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
343 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
6k 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 ...
2
votes
2answers
3k 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
38 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 ...