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
1
vote
0answers
19 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. ...
3
votes
2answers
63 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 ...
-2
votes
0answers
19 views

Graph dfs-related code passes almost all test cases, fails on a few [closed]

I have a following problem and corresponding code: You have a rectangular field of size NxM. You have K marked cells. N,M,K and marked cells coordinates are read from an input file. Two marked cells ...
3
votes
1answer
64 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 ...
5
votes
2answers
292 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 ...
2
votes
1answer
38 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 ...
3
votes
1answer
63 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 ...
13
votes
3answers
1k 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 ...
1
vote
0answers
34 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. ...
0
votes
1answer
25 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 ...
2
votes
0answers
53 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 ...
3
votes
1answer
111 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 ...
4
votes
1answer
89 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: ...
1
vote
2answers
78 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" ...
1
vote
1answer
71 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 ...
1
vote
2answers
129 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 ...
3
votes
2answers
455 views

Simple Hashmap in C

I've been working on a simple hashmap in C. Here is hashmap.h: ...
4
votes
3answers
141 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 ...
0
votes
1answer
57 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 ...
3
votes
0answers
67 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 ...
2
votes
1answer
65 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. ...
2
votes
0answers
42 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 ...
1
vote
1answer
49 views

group list of dictionary [closed]

I have a list of dictionaries and I want to group them by a specific value let's say this is the list: ...
5
votes
1answer
65 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 ...
4
votes
1answer
119 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 ...
5
votes
1answer
89 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-...
3
votes
1answer
64 views

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

So 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 this library (https://github.com/...
2
votes
0answers
34 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 ...
7
votes
2answers
572 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 ...
3
votes
2answers
32 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 ...
10
votes
2answers
2k 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 ...
4
votes
2answers
196 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 ...
2
votes
2answers
144 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 ...
4
votes
1answer
48 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 ...
5
votes
1answer
120 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 ...
5
votes
1answer
135 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/...
5
votes
1answer
55 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 ...
3
votes
0answers
74 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. ...
5
votes
1answer
154 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 ...
5
votes
2answers
229 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 ...
2
votes
1answer
46 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 ...
2
votes
0answers
41 views

Linkedlist & hashmap _duplicates removal

I have implemented a LinkedList removal fo duplicates class by using HashMap. Looking forward to your reviews. Thanks. ...
1
vote
1answer
40 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: ...
3
votes
1answer
143 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, ...
-3
votes
1answer
39 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 ...
3
votes
3answers
120 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 ...
2
votes
0answers
45 views

Trie to index files and search for them

Basic idea (foo and foa are filenames): ...
2
votes
1answer
63 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 ...
3
votes
2answers
205 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 ...
7
votes
5answers
2k 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 ...

1
2 3 4 5
17