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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:25:38+00:00 2026-05-11T10:25:38+00:00

I recently read that a method involving hashing could be a good way to

  • 0

I recently read that a method involving hashing could be a good way to find the mode of an array of floating point numbers. I don’t know much about hashing or its applications and the text didn’t explain further.

Does anyone know what this method would involve?

  • 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-11T10:25:39+00:00Added an answer on May 11, 2026 at 10:25 am

    Not being much of a statistics guy, the mode in this sense seems to be defined as ‘the value that occurs the most frequently’.

    From that description, it seems the obvious way to implement this using a hash table would be to use the number as a key, and as the value stored, use a frequency counter.

    Then just loop through each number, in Python pseudo-code this would be something like:

    array = [1.0, 1.2, 0.4, ...] # A bunch of numbers counts = {} for a in array:   if a in counts:     counts[a] += 1   else:     counts[a] = 1 

    Then you’d need to extract the greatest value, and find its corresponding key:

    sorted([(v, k) for k, v in counts.items()])[-1][1] 

    This creates a sorted list of (value, key) pairs, sorted on value, and then extracts the key (1) from the last ([-1]) pair.

    I didn’t bother using a defaultdict or equivalent, for illustration I think the if is rather helpful.

    NOTE: I make no guarantees that this is the canonical way of solving the problem. This is just what I’d do, off the top of my head, if someone asked me to solve the problem (and maybe hinted that using a hash is a good idea).

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

Sidebar

Related Questions

I recently read in Code Complete that the recommended way of handling expressions that
I recently read that getters/setters are evil and I have to say it makes
I recently read somewhere that writing a regexp to match an email address, taking
I've read recently that iOS is message based. Is that similar to an event-based
I recently read in a presentation on Scribd that Facebook had benchmarked a variety
I recently read through Code Complete, and it recommends that I create a project
Recently i read an article is about prevent brute-force attack. It said that automatically
I've been working with UDP sockets quite a lot recently. I've read that UDP
I was working on some code recently and came across a method that had
Recently I found out the hard way that to convert between LatLngs and pixel

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.