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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:25:23+00:00 2026-06-13T16:25:23+00:00

I’m looking for a simple to implement algorithm that can find the row of

  • 0

I’m looking for a simple to implement algorithm that can find the row of a table having the maximum value on a certain column. Then, it should find all the rows that have a value close to the maximum on that particular column (can these 2 steps be combined?). Then, out of the selected rows, I need to find the one that has the minimum value on another column.

Bonus: in case there are several such entries, I need to find the row having the minimum value on another column.

Yes, I am aware that it’s easy to do this with SQL(ite), but I don’t want to waste time parsing the data from my text file into a database table…

I am interested in a simple idea on how to do this (pseudocode is fine) and, right now, I can only think of something rather complex along these lines:

  • iterate over all rows & find maximum
  • iterate over all rows and insert the ones that are “close” to the maximum in a list
  • find minimum value in the new list of rows
  • 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-13T16:25:25+00:00Added an answer on June 13, 2026 at 4:25 pm

    Actually you are doing the right thing. Unless your row values are already sorted, you can’t avoid going through all values in step 1, so you will end up spending O(R) time in there, where R is the number of rows.

    For the second step, its cost is also O(R) so it doesn’t degrade your algorithm’s complexity.

    If we consider that the number of values “close to the maximum” is O(1) with respect to R, then the third step is O(C) where C is the number of columns. You can’t do better than this if your values aren’t sorted because you need to test all values in order to find the minimum.

    Your algorithm has the best complexity you will get.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.