Questions tagged [hash-map]

A data structure that uses a hash function to map identifying values, known as keys, to their associated values

Filter by
Sorted by
Tagged with
2 votes
1 answer
189 views

Hash Table implementation in C using linear probing for collisions

I've written a simple Hash Table implementation in C, in order to use it in an IRC bot, so mostly storing nicknames, channel names, etc (small strings). I'm using linear probind to resolve collision. ...
Thibaut D.'s user avatar
3 votes
2 answers
124 views

Create a dictionary from a list of key and multi list of values in Python

I have a list of key: list_date = ["MON", "TUE", "WED", "THU","FRI"] I have many lists of values that created by ...
Scorpisces's user avatar
3 votes
1 answer
73 views

Aggregating hourly location data into daily sublocation data for many columns

I start with an hourly table that has around 40 of items (example: bread, barley, bagels, beef, chicken). The purpose of my code is to aggregate this hourly table's numbers to daily numbers but broken ...
Evan Friedland's user avatar
5 votes
2 answers
2k views

Hash table implemented in C with open addressing

While posting this, I noticed there are quite a few similar C hash table implementations here already. So I figured one more wouldn't hurt. :-) In any case, I'm writing a teaching article on "how ...
Ben Hoyt's user avatar
  • 599
2 votes
1 answer
59 views

Linked list that support modifications during iteration

Update: Fixed last item is not removed during iteration Fixed clear() during iteration does nothing Fixed addition of removed item is ignored The lasted code can ...
Ilya Gazman's user avatar
5 votes
1 answer
344 views

lazy_map implementation in C++ | Similar to unordered_map but O(1) copyable

I implemented lazy_map - https://github.com/tinytrashbin/lazy_map. Can someone help with reviews ? lazy_map is an implementation of unordered_map that has O(1) cost of copying irrespective of the ...
Mohit Saini's user avatar
14 votes
3 answers
3k views

Count word frequencies, and print them most-frequent first

I'm writing a comparison of a simple word-counting program in various languages. The task is to count the frequencies of unique, space-separated words in the input, and output the results most ...
Ben Hoyt's user avatar
  • 599
1 vote
0 answers
54 views

Global Dictionary Class

For a Django-Server I use several custom Error-Codes, error-titles and descriptions, possibly other fields might follow. I'm using right now a basic global dictionary. ...
Qohelet's user avatar
  • 151
0 votes
1 answer
60 views

Calculating ordered differences between elements in vector

Input I start with a vector of integers or floats, e.g.: [10, 100, 20, 5, 50] Output I want to return a list of differences or "deltas" between elements ...
Alex Reynolds's user avatar
3 votes
1 answer
127 views

Hash table library implementation

I wrote my own implementation of generic hash table. I’m using linked list to resolve collision problem. I want to share my code with you and get your opinion about it, and if there are any advice or ...
Abdelhakim RAFIK's user avatar
3 votes
1 answer
922 views

Hashtable with separate chaining and dynamic resizing

An attempt at a clean implementation of this important data structure in C. It's hard to make such structures generic in C without losing performance, so this specialises on ...
Oliver Schönrock's user avatar
4 votes
1 answer
102 views

Data set with many variables in Python, many indented dictionaries?

I am working with a data set that has many variables. Currently I am storing the data in many indented dictionaries in the following way: ...
user171780's user avatar
1 vote
2 answers
331 views

Finding duplicates in multiple lists for configuration validation

I have created helper class for configuration validation, the main purpose is to find any human "errors" in the configuration for the app. the case is that any type of "message" ...
Arkady Levin's user avatar
2 votes
1 answer
840 views

Generic hashmap with dynamic resizing and collision handling

This is a (more or less) continuation of a previous post I made: Generic implementation of a hashtable with double-linked list. I got lots of valuable feedback, so I decided to rewrite the entire ...
766F6964's user avatar
  • 901
1 vote
2 answers
6k views

How to make Map<String, Object> expendible(?) safely in java

I am building some statistic counter in Java. Each metric could have flexible depth so the implementation should able to explore the depth when value insert or update. So I implement like below (with ...
Juneyoung Oh's user avatar
3 votes
2 answers
7k views

Simple Hashmap in C

I've been working on a simple hashmap in C. Here is hashmap.h: ...
xilpex's user avatar
  • 289
4 votes
3 answers
501 views

Generic implementation of a hashtable with double-linked list

I implemented a hashtable that handles collisions by chaining entries using a double linked list. The idea is that it can store/lookup any kind of generic data structure, while maintaining an API that ...
766F6964's user avatar
  • 901
0 votes
1 answer
952 views

Nested dictionary creation with setdefault

Is there a better way of creating a nested dictionary than what I'm doing below? The result for the setdefault is because I don't know whether that particular key ...
mlevit's user avatar
  • 113
2 votes
0 answers
81 views

Modeling data from Excel sheets to parse to Excel sheet

Background: I have close to 50 excel files - I cannot change the data source - and I steadily get more. My task is to make sense of all that data and, lo an behold, save that as another excel file (I ...
Nacorid's user avatar
  • 121
2 votes
1 answer
107 views

Print the App Name Using Latest Version

I am trying to solve a problem, where we are given an app name, service name, and version number of an api. We need to print the name of app, which is using the latest version for most of the service. ...
vikash srivastava's user avatar
2 votes
0 answers
71 views

Hashtable Visualizer in TypeScript

Implementation is based on the MVC design pattern, with callbacks to allow model and view to communicate with controller. Concerns: It's not ideal to have async code inside the model, i.e the model ...
L292092's user avatar
  • 419
4 votes
1 answer
442 views

Basic Markov Chain Algorithm

So I have a file(story.dat) with a randomly generated story like: "Sleeping in his car was never the plan but sometimes things don't work out as planned. This..." It will print out each word ...
GigaHiga's user avatar
4 votes
1 answer
175 views

Increment value in a list of dictionaries

I have a list of dictionary let's say : l=[{'a':1,'b':2},{'a':5,'b':6},{'a':3,'b':2}] and I want to have another list l2 and add 4 to the 'a' in the all ...
user3379546's user avatar
5 votes
1 answer
698 views

Find the shortest sub array that contains all element from 1 to K

I'm trying to solve this problem here. The question is all about finding the shortest sub array inside an array that contains all the element from 1 to K. Input: The first line contains three space-...
arctic_Oak's user avatar
4 votes
1 answer
180 views

Function for accessing and searching dictionaries using /slashed/paths (like xpath)

I have some data being returned to me in the form of a deeply nested Dict and I need to parse multiple values from it which may or may not be there. I saw the dpath ...
ScrapeHeap's user avatar
2 votes
0 answers
39 views

Converts Pandas and Numpy into Dictionary and Converts back to original format for data split

I'm trying to refactor some code so that it does not have so much repetition to it. What I'm trying to do is create an input for a multiple channel/input neural network. The features that are being ...
machine_apprentice's user avatar
7 votes
2 answers
784 views

Number of occurrences of strings in array

This is a Hackerrank problem (https://www.hackerrank.com/challenges/sparse-arrays/problem). We're given an array of strings and an array of queries, and have to return an array of the number of ...
jeremy radcliff's user avatar
3 votes
2 answers
423 views

Handle missing children nodes when parsing XML into a dictionary

I work on a code-base that uses xml to set up problems and specify model parameters. I've created a script that I run in tandem with our code. This script will ...
dylanjm's user avatar
  • 225
9 votes
2 answers
21k views

first pizza order program

Trying to learn a new skill at 40 without any prior related experience :-) Bought the book 'Python crash course 2e' and decided to freewheel a bit with after a week with what I've learned so far.. I ...
Osman Polat's user avatar
4 votes
2 answers
693 views

JavaScript implementation of Symbol Table (Dictionary)

I'm currently going over Robert Sedgewick Algorithms book. Here I'm implementing a Symbol Table using a Linked List. The Sequential Search Symbol table is implemented in JavaScript. The book mentiones ...
Steven Aguilar's user avatar
2 votes
2 answers
191 views

Finding unique keys

I made the following snippet. It finds unique keys based on their values. For all keys \$s\$ that are contained in another key \$D\$ with the same value, key \$s\$ is discarded and key \$D\$ is ...
Victor Adeyemo's user avatar
4 votes
1 answer
512 views

Add lines from files to corresponding dictionaries

I have to iterate through multiple text files. For each file I read its contents and append each line to its corresponding dictionary to then build a JSON file. Each text file has the following ...
CYREX's user avatar
  • 41
5 votes
1 answer
138 views

python3 function to merge dictionaries

I have a bunch of JSON records, each record with a varying degree of completeness. In other words, record A may contain keys not in record B, and vice-versa. To get a better understanding of the data ...
wiggitywacker's user avatar
7 votes
1 answer
1k views

Recursively merge n-level maps of values and lists

I was looking for a solution for a way to easily merge maps of serialized Yaml and came up with this. Reference to a similar question (not asked by me): https://stackoverflow.com/questions/25773567/...
Zhro's user avatar
  • 249
5 votes
1 answer
72 views

Dynamic-sized Hash table with Linked List

Below is an implementation heavily based on climberig's implementation on Leetcode for LeetCode 706. Design HashMap. Just to preface, I am doing this in preparation for an exam. The one below is ...
Alex Goncalves's user avatar
3 votes
0 answers
218 views

Linear probing 16 hashmap elements in parallel using SIMD instrinsics

For my hashmap implementation, I'm caching hashes for each map element in an array of length NBUCKETS, where each element corresponds to an element in the hashmap. ...
gtmshrm's user avatar
  • 31
5 votes
1 answer
2k views

Dictionary implementation in Rust

This is an implementation of a dictionary (hash map) in Rust. It is loosely based on Python's dictionary implementation, using the same "random" probing and capacity/size management. Does it ...
EphraimRuttenberg's user avatar
5 votes
2 answers
373 views

Can it be shorter?: DNA Sequence Analyzer from CS50 written in Python

This is my first time requesting a code review. This is code I wrote in Python to create a DNA sequence analyzer. This is for the Harvard CS50 course. I was really hoping to get some constructive ...
Star's user avatar
  • 61
2 votes
1 answer
55 views

Optimize insertion from ArrayList to HashMap

I'm trying to insert data from ArrayList to HashMap<String, Language> optimally. Many items may have the same languge_name (code below), so I need to group items having the same language in ...
dev1's user avatar
  • 23
2 votes
0 answers
51 views

Linkedlist & hashmap _duplicates removal

I have implemented a LinkedList removal fo duplicates class by using HashMap. Looking forward to your reviews. Thanks. ...
Neslihan Bozer's user avatar
1 vote
1 answer
259 views

Designing a hashset with LinkedLists as buckets

I am solving a problem on Leetcode that requires me to design a hash set. I intend to solve it using linked lists where each linked list would represent a bucket. I am intending to implement this: ...
Aviral Srivastava's user avatar
3 votes
1 answer
305 views

Add values from a dictionary to subarrays using numpy

I'm working with numpy arrays and dictionaries, the keys of the dictionary are coordinates in the numpy array and the values of the dictionary are a list of values I need to add in those coordinates, ...
Carlos Eduardo Corpus's user avatar
-3 votes
1 answer
52 views

I am trying to save a string to a MYSQL table from a radiobutton in java/Android studio [closed]

I am trying to save a radiobutton string if it clicked. I am making a survey where I need to save a "yes" or "no" into a MYSQL table using volley. I am having a little trouble ...
Connor Daly's user avatar
3 votes
3 answers
173 views

Optimize Memory Java String Array

I was trying to solve one programming challenge : First input is a list of connections which is made of pair of IPv4 address. Each IP has its own state which starts with false, each connection also ...
Learner's user avatar
  • 133
2 votes
0 answers
142 views

Trie to index files and search for them

Basic idea (foo and foa are filenames): ...
user227408's user avatar
2 votes
1 answer
74 views

Updating a dictionary of trajectories after a step has been made

I am using a dictionary to save possible trajectories in a game. A trajectory is defined as a list of numbers separated by _. For example ...
3sm1r's user avatar
  • 143
3 votes
2 answers
977 views

Set default value for remaining size of list by use of Java 8 and Stream

I have written a method which will return the size 16 List every time. If the input List has size less than 16, the remaining list object will be filled with default values.  Is there any way to ...
user3789184's user avatar
11 votes
6 answers
18k views

Enhanced Hashmap - Add a number to all keys/values

I had the below problem in a coding test and I got 28/30 tests passes and 2 failed due to a time-out. Problem You have created a programming language and now you have decided to add ...
Praveen's user avatar
  • 228
3 votes
1 answer
282 views

Function takes a dictionary with list as value, returns the key of the biggest list

I created a function that takes a dictionary as parameter. This dictionary is expected to have lists as value pair. (i.e. {1: [1, 2, 3], 'a': [4, 'b', 5, 'c']} ) ...
msmilkshake's user avatar
1 vote
1 answer
18 views

A structure for a text messages dictionary with system notifications/errors

I would like to arrange a system messages dictionary for an application in JavaScript. As an initial intention, I thought something about the following structure: ...
Mike's user avatar
  • 277

1 2
3
4 5
19