Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 73609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:13:42+00:00 2026-05-10T20:13:42+00:00

Are there any known hash algorithms which input a vector of int’s and output

  • 0

Are there any known hash algorithms which input a vector of int’s and output a single int that work similarly to an inner product?

In other words, I am thinking about a hash algorithm that might look like this in C++:

// For simplicity, I'm not worrying about overflow, and assuming |v| < 7. int HashVector(const vector<int>& v) {   const int N = kSomethingBig;   const int w[] = {234, 739, 934, 23, 828, 194};  // Carefully chosen constants.   int result = 0;   for (int i = 0; i < v.size(); ++i) result = (result + w[i] * v[i]) % N;   return result; } 

I’m interested in this because I’m writing up a paper on an algorithm that would benefit from any previous work on similar hashes. In particular, it would be great if there is anything known about the collision properties of a hash algorithm like this.

The algorithm I’m interested in would hash integer vectors, but something for float vectors would also be cool.

Clarification

The hash is intended for use in a hash table for fast key/value lookups. There is no security concern here.

The desired answer is something like a set of constants that provably work particularly well for a hash like this – analogous to a multiplier and modulo which works better than others as a pseudorandom number generator.

For example, some choices of constants for a linear congruential pseudorandom generator are known to give optimal cycle lengths and have easy-to-compute modulos. Maybe someone has done research to show that a certain set of multiplicative constants, along with a modulo constant, in a vector hash can reduce the chance of collisions amongst nearby integer vectors.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:13:43+00:00Added an answer on May 10, 2026 at 8:13 pm

    I did some (unpublished, practical) experiments with testing a variety of string hash algorithms. (It turns out that Java’s default hash function for Strings sucks.)

    The easy experiment is to hash the English dictionary and compare how many collisions you have on algorithm A vs algorithm B.

    You can construct a similar experiment: randomly generate $BIG_NUMBER of possible vectors of length 7 or less. Hash them on algorithm A, hash them on algorithm B, then compare number and severity of collisions.

    After you’re able to do that, you can use simulated annealing or similar techniques to find ‘magic numbers’ which perform well for you. In my work, for given vocabularies of interest and a tightly limited hash size, we were able to make a generic algorithm work well for several human languages by varying the ‘magic numbers’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 146k
  • Answers 146k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SELECT t1.id FROM mytable1 t1 --SPECIFY JOINs HERE inner join… May 12, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer You have to first decode the quoted-printable encoding. This is… May 12, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer You must specify a padding mechanism when you call Cipher.getInstance()… May 12, 2026 at 9:00 am

Related Questions

Are there any known hash algorithms which input a vector of int's and output
Is there an algorithm to estimate the median, mode, skewness, and/or kurtosis of set
I have a very large possible data set that I am trying to visualize
I have been noticing some very strange usage of O(1) in discussion of algorithms
This is not exactly a technical question, since I know C kind of enough

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.