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
5
votes
2answers
1k views

Hash Table: adding and finding functions

I made this function to teach myself about hash tables. Any ideas? I commented out free(addition) because it was giving me a compiler error, but I need to figure ...
3
votes
2answers
230 views

Nested array-to-dict transformation

I'm looking to let people define arbitrarily nested lists of lists and return a random json document for them. Right now the assumption is that if you have a structure like this: ...
2
votes
2answers
385 views

Fast integer handling

Each data structure has its own time complexities. The biggest one that jumps out at you is the hash table. The average times for Insertion, Deletion and Searching are all O(1). But it's really ...
4
votes
1answer
122 views

Object map in JavaScript

I want to make a map object that key is object. But, JavaScript only allows string as a hash key. (at least before ECMAScript6 comes?) So, I tried to write auxiliary functions to emulate, hash-ish (...
5
votes
2answers
5k views

HashTable - separate chaining collision in C++

I'm trying to implement a HashTable. In fact, I want a HashSet with Persons that have a name and a phoneNumber, both string. I understood the theory with collisions and everything but I don't know how ...
11
votes
2answers
22k views

Hash table implementation in Java

For class, I was asked to write a (linear probing) hash table in Java. (I was also asked to write a linear-chaining hash table, which is why I named this one ...
7
votes
3answers
14k views

Two Key HashMap

Background Would like to create a two-key map that is fairly generic. In the existing system, there are a number of ways to name a parameter for a report. Rather than re-writing each report (too much ...
2
votes
1answer
306 views

Iterating X times (where X > Y) over Y element dictionary

I need to write a procedure, that will take a dictionary consisting of server names and their available slots and a number of slots required, and redispatch it over the servers, so that every server ...
2
votes
1answer
347 views

Readability concerns with literal dictionary lookup vs if-else

I'm having concerns about readability of this piece of code: messages_dict = {'error':errors, 'warning':warnings}[severity] messages_dict[field_key] = message ...
2
votes
1answer
396 views

Simplify complex hash-table manipulations in Common Lisp

I'm trying to write a simple triplestore in Common Lisp that will store triples in the form subject-predicate-object. The code is inspired by the book "Programming the Semantic Web". ...
5
votes
1answer
5k views

Hash table using open-addressing with linear probing

I've written a hash-table implementation. This is the first time I've written such code. The hash-table uses open-addressing with linear probing. The hash function is still subject to change as I ...
7
votes
3answers
17k views

Implementation of hash map

I was asked to implement a hash map in this phone interview (screen-share), so time was limited and this is what I came up with. I'd appreciate if someone can take a minute to critique/review it and ...
2
votes
1answer
4k views

Open addressed hash table

I'm attempting to implement various data structures and algorithms to better learn C. I would appreciate comments on style, correctness of the implementation, memory management, etc. One specific ...
25
votes
8answers
47k views

LINQ approach to flatten Dictionary to string

I have a Dictionary<string,string> and want to flatten it out with this pattern: ...
2
votes
2answers
1k views

File to map class

This code will be used to map a set of unique keys to a container of objects that are unique to that key. I would like to be able to reuse this code in future projects hence the template, and not hard ...
6
votes
1answer
195 views

Overlapping table fragments

One of my side projects is a table driven scanner/parser generator, in an effort to reduce the size of the transition table I represent the generated table A[x, y] ...
11
votes
2answers
4k views

Improving HashMap in C++

I have created a HashMap<string,int> in C++. I would like help determining if it is good or bad. I have not handled the errors or successes with messages. I ...