Questions tagged [hash-collision]

a situation that occurs when two distinct pieces of data have the same hash value, checksum, fingerprint, or cryptographic digest.

See also the wiki tag.

212 questions
0
votes
1 answer

Hashed array linked list collision resolution error

This block of code reads a dictionary file and stores it in a hashed array. This hashing array uses linked list collision resolution. But, for some incomprehensible reason, the reading stops in the middle. (i'm assuming some problem occurs when…
slow
  • 733
  • 3
  • 11
  • 25
0
votes
10 answers

Chaining in HashMap

Code: public static void main(String[] args) { Map map= new HashMap(); map.put("a", "s"); map.put("a", "v"); System.out.println(map.get("a")); } Now, as per my understanding, since the key values in…
Kraken
  • 20,468
  • 32
  • 90
  • 145
-1
votes
2 answers

How to check if there are collisions in C# Dictionary?

It's possible to get the map's bucket size in C++ to check the collision status but I couldn't find a way to do that in C#. How can I know if Dictionary has been collided? I want to test my custom hashing function, because even though the function…
phuclv
  • 27,258
  • 11
  • 104
  • 360
-1
votes
2 answers

Value modification of key-pair in HashMap and impact for a HashCode

A few days ago I had an interview and there a few interesting questions occurred. Namely, the recruiter asked me meticulous questions. Some of them concerned the close relationship between HashCode and the collections, which are based on the…
Martin
  • 695
  • 1
  • 10
  • 26
-1
votes
1 answer

Dealing with python hash() collision

I've created a program to take a users predetermined unique identifier, hash it, and store it in a dictionary mapping to the user's name. I later receive the unique identifier, rehash it, and can look up the user's name. I've come to a problem…
-1
votes
1 answer

Will similar Strings in HashMap lead to increased chance of collisions?

Consider the following: HashMap hm = new HashMap<>(); final String prefix = "My objects "; int counter = 0; void put(Object value) { hm.put(prefix+(counter++), value); } Given that the key of each entry starts with the same…
Sina Madani
  • 1,035
  • 1
  • 13
  • 26
-1
votes
1 answer

How to determine whether to overwrite a value or use a collision strategy? (Java HashMaps)

I have been implementing a hashmap from scratch and this dawned on me. Lets say I have 3 distinct keys and 3 values Keys -> Value: A -> 1, B -> 2,C -> 3 and they each land in an open slot in the array. If the fourth key D produces the same…
Rstack
  • 45
  • 9
-1
votes
2 answers

Hash Collisions even after overriding equals and hashcode methods for object being stored as key in Hashmap

I need to store object type of class edge as Key and ArrayList as Value public class edge { String edgeType; // Horizontal or Vertical edge int i; //i and j for a cell in 2D matrix int j; } HashMap>…
-1
votes
1 answer

Hash table collision-handling schemes and the load factors

Which of the hash table collision-handling schemes could tolerate a load factor above 1 and which could not? Thank you in advance!
CSstudent
  • 33
  • 5
-1
votes
1 answer

Reducing size of hash

If I have some data I hash with SHA256 like this :- hash=SHA256(data) And then copy only the first 8 bytes of the hash instead of the whole 32 bytes, how easy is it to find a hash collision with different data? Is it 2^64 or 2^32 ? If I need to…
Harry
  • 201
  • 2
  • 8
-1
votes
1 answer

How to generate random number without repetition in java using hash function

I want to add a shuffle option in my android music player app. For that purpose i am calling a random function in java to return a number between 0 and size of the currently playing songs list. The problem is that the function returns same value as…
Shanij P.S
  • 137
  • 3
  • 8
-1
votes
1 answer

Collision generators or Datasets for hash collisions (like MD5, SHA-1 ...)

I'd like to test 3rd party (including "closed source") tools (like synchronization, de-duplication...) behaves in presence of files with same size and digest checksum (popular ones CRC32, MD5,SHA-1 ... etc). Some of those hashing methods have known…
-2
votes
1 answer

go maps non-performant for large number of keys

I discovered very strange behaviour with go maps recently. The use case is to create a group of integers and have O(1) check for IsMember(id int). The current implementation is : func convertToMap(v []int64) map[int64]void { out :=…
zaRRoc
  • 255
  • 4
  • 16
-2
votes
2 answers

Implementing HashMap: Avoid collisions caused by compress function

I'm implementing a hashmap to contain all words in a word file (e.g dictionary.txt, bible.txt) and I am having a collision problem. I know that there are many good hash functions out there but when I try compressing the hash code using this…
Mike Pham
  • 187
  • 1
  • 10
-2
votes
1 answer

Fast and (practically) collision free hash

I have an object which calculates a (long) path. Two objects are equal if the calculates the same path. I previously tested if two objects were equal by just doing something like: obj1.calculatePath() == obj2.calculatePath() However, now this has…
Markus
  • 2,306
  • 3
  • 23
  • 34
1 2 3
14
15