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

learn more… | top users | synonyms (1)

1
vote
2answers
53 views

Alternative to using Object and casting in a map

I have the following class which represents a set of properties. ...
2
votes
0answers
38 views

HashMap with Binary Search Tree for Chaining

My friend was asked to implement a hashtable with a binary search tree. I tried practicing it myself, and it turned out to be very verbose. Need suggestions to clean this up! ...
2
votes
3answers
47 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: ...
2
votes
3answers
282 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. ...
2
votes
1answer
51 views

Bare bones implementation of Java HashMap

I've done a minimal implementation of a HashMap. Invite comments. ...
4
votes
1answer
61 views

Prints Books from a HashMap that are complete or incomplete

This code is meant to display book titles that are incomplete. I have a HashMap with the book title and a number that represents the amount of the book that has ...
2
votes
2answers
71 views

Print max occurring character in a String

This prints the character that occurs the most in a given string. Input: String of word(s) Output: Max occurring character ...
3
votes
1answer
50 views

class Taboo<T> — sort passed in List<T> according to 'rules'

I know as a matter of fact that there are many areas upon which my code could be improved. I was wondering if anyone can provide me with suggestions on how Taboo ...
0
votes
3answers
124 views

Detecting if two given strings are isomorphic using Java data structures

So I have written the following code and it works for various same length isomorphic strings I have tried. However I am not sure what are some time complexity improvements and coding tweaks that could ...
0
votes
0answers
17 views

Converting from a madlib program using hashmaps to using 3 different arrays to hold the noun, verb, and adjectives

Using erb and Sinatra, I need to make an array of each variable that can be added in, [noun], [verb] and [adjective], allowing me to return the number of each there are and create the appropriate ...
5
votes
1answer
119 views

Replacing multiple substrings in a string

Here are 2 functions defined that do the exactly same thing: take input a template (in which one wants to replace some substrings) and array of strings values (key value pair to replace, such as [...
4
votes
2answers
79 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
1answer
106 views

A basic pure Python hash map using a tree

I would like feedback on my first attempt to understand how hash tables work. I've read some on how hash tables use modulo operations to find the location of a key. Can you help me understand, ...
4
votes
1answer
87 views

Evicting an entry from a size-limited HashMap<T, Integer>

I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one. I already have this working ...
3
votes
1answer
59 views

“Space and Time Efficient” way of finding all anagram groups

I have written a program to find all anagram groups in a text file. I used first 26 Prime numbers as a mapper for 26 characters for finding anagram groups (Since character_set of all anagrams of a ...
8
votes
2answers
455 views

Program to index a book

Indexing a book. Write a program that reads in a text file from standard input and compiles an alphabetical index of which words appear on which lines, as in the following input. Ignore case and ...
3
votes
2answers
117 views

Custom C++ iterator

So I have written a custom iterator for std::map that allows access to just the "values" of the map and I was wondering if it is the "correct" way to implement <...
5
votes
2answers
158 views

Registering and looking up aliases

I've taken a coding challenge as part of a job interview and the recruiting process. Sadly I didn't get through it and couldn't secure the job. I am wondering if anyone can help me out here and show ...
0
votes
3answers
96 views

Database of students

At first, I had Database to contain std::list<Student> students, but because there are over 2000 students, searching by ...
10
votes
2answers
1k views

Implementation of fixed size hash map

I'm trying to brush up on my algorithms and data structures and wrote a fixed sized hash map assuming both key and value will be only integers. This is a significant simplification of the real case ...
4
votes
2answers
941 views

Performance of hashmap-based session object

Unfortunately, I can't use the Tomcat session for storing the key/value pairs for each user (restricted because it's an IVR domain-based project). But I need the same functionality like a ...
6
votes
4answers
24k views

Simple implementation of HashMap

I have implemented a HashMap which supports insertions of integer key value pairs. The approach uses an array for simplicity and uses a standard hash function. ...
11
votes
2answers
9k views

Object key-value map reversal

I have implemented functions that will let me reverse a one-to-many value 'Map', that is a plain JavaScript object. For example, ...
5
votes
2answers
155 views

Family finances - tracking and reporting

I am looking for clean way to accumulate amounts within a input dataset. In this example, there are 18 rows of data, and the output is a 3 rows of data, accumulated by Key, by ExpenseType. My ...
19
votes
3answers
8k views

More elegant way to increment Integers in Map?

I have a HashMap<Token, Integer>, which counts occurrences of Token. Each time Token ...
6
votes
1answer
68 views

Implementing a data structure that is a collection of sets

I'm trying to optimize my code (time optimization) based on this problem: Let S be a set of strings. Each string in S is ...
2
votes
2answers
325 views

Counting occurrences of Char8s in a file

To learn some Data.Map and Control.Monad.State, I have written the following code, which should count the occurrences of ...
2
votes
1answer
1k views

Generic util method to convert in single map from list of array of Object generally result of JPQL/ hibernate

I have designed a generic method to convert list of array of Objects to result into single map. This is working fine, but I want to check weather a key object is valid key (whether it is overriding ...
3
votes
1answer
608 views

Trains scheduled, find max platforms per stations

Given a "folder" which contains many "files," each file contains a time-table of trains, which stations they halt on and what time, per day. ...
10
votes
1answer
1k views

Is this the right way to implement a hashmap?

Is this the right way? Any comments on the hash functions? If asked a question like this in an interview, do I need to follow all OOP concepts(because I am using Java)? Like encapsulating the ...
11
votes
1answer
664 views

Partitioned Multikey Map

Below is the code for what I've called a partitioned_multitype_map. This has two major facets: Allowing a lookup based on keys of multiple lengths and of multiple ...
6
votes
3answers
327 views

How to refactor this code to get a source from property files?

I want to get the source of these files, but I don't know if I'm efficient. I get the source of the file, put the source in a list, so I put this in a ...
4
votes
3answers
1k views

Find the longest unique string in the input list

Given a list, find the longest non-repeating (in other words I mean unique) string in the input list. Looking for code review, pointers on best practices, optimizations etc. ...
4
votes
1answer
835 views

Insert tags around entities in body

Because we're passing object to Spring Framework in which Jackson classes convert them into JSON as a response, we chose to implement a simpler Tweet class rather ...