2

I'm currently learning about hash table. Hashing integers are easy, but my assignment is to hash strings. I have given strings:

25674316-6058714                
56105665-7450612                
96917015-1417157                
48189873-3313151    

I have to hash them to fit into array of buckets[4]. How do I hash strings?

1
  • size_t hash = std::hash<std::string>()(myString); Commented Jul 23, 2018 at 4:08

1 Answer 1

4

With the standard libraries hash function:

std::string stringToHash = "25674316-6058714";
size_t result = std::hash<std::string>()(stringToHash);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.