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 8882935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:49+00:00 2026-06-14T20:41:49+00:00

I had interview yesterday, and I had such question – there is server and

  • 0

I had interview yesterday, and I had such question – there is server and database, which store big text information(every text can be >10 Mb). Any query to database is expensive. You need to design a program(server) which will take a text and say – is this text in database or not.

I request such decision –
Make a good hash of every text. Then make a set of all hashes. If hash of input text is not in set – so there is no such text, else – go to database and try to find this text by hash and equal deeper. Minus of such decision that it can be a lot of texts in database, so set will be a bit bigger=)
May be your know how to solve it right?

  • 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. Editorial Team
    Editorial Team
    2026-06-14T20:41:50+00:00Added an answer on June 14, 2026 at 8:41 pm

    As discussed in the comments, the basic concept is to reduce the number of queries to the database by eliminating query texts that cannot possibly be in the database.

    As you suggest, hashing is an excellent way to do this – if you use a good hash function (i.e. low probability of collision) then you would never need to actually compare the texts, since you would (almost certainly) never get a false positive.

    A variant of hashing (if memory becomes an issue) is to use a Bloom Filter: “a space-efficient probabilistic data structure that is used to test whether an element is a member of a set.” This approach uses far less memory than plain hashing, at the expense of some false positives (i.e. occasionally you would need to compare a text with the database to make sure whether you had a match). Bloom filters let you adjust the tradoff between memory and false positive rate. They are used in NoSQL databases such as BigTable and Apache Cassandra.

    Update as David Schwartz rightly points out, the hash function does matter, particularly in the case where a significant propertion of the queries are in the database – see our discussion in the comments below. Same issue applies to Bloom filters which are ideal when you want to narrow down your disk access to a small subset of files (for example) but not for eliminating disk/database access entirely, because of the false positives. I originally mentioned MurmurHash3 by way of a speed benchmark, but because it is non-cryptographic, it is unsuitable for this question. When I actually implemented approaches like this in the past, I used SHA1, which is cryptographic.

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

Sidebar

Related Questions

Yesterday i had a question in an interview which i thought i could find
Had this question in the interview yesterday. Which is better to use? Infix(with parenthesis)
Yesterday i had this interview question, which I couldn't fully answer: Given a function
I had a following interview question. There is an array of nxn elements. The
I had an interview question asking this: text file has following lines> 1: A
Recently i had an interview in which the question was asked as How would
In an interview they had asked an Question like this there are three overloading
This is one of an interview question which I had recently. I would like
I had an interview today which involved this very question and in order to
Yesterday, I had an interview. There they asked me when the code optimization happens?

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.