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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:18:21+00:00 2026-05-28T02:18:21+00:00

I am stuck on this problem and was wondering if anyone could help me

  • 0

I am stuck on this problem and was wondering if anyone could help me out:
There are n houses on the x-axis {x_1, x_2,…x_n}, I need to find the location on the x-axis that gives me the smallest sum of distances between the houses and the location.

This is trivial of course, but I also need to be able to do it in O(n) time, and I am stuck on the dynamic algorithm.

Edit: Apparently it did not need to be a DP algorithm, which as I said makes it trivial, sorry for the confusion, and thanks for the responses.

  • 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-05-28T02:18:21+00:00Added an answer on May 28, 2026 at 2:18 am

    I know median finding reasonably well, and I know dynamic programming reasonably well, but I don’t know of any median finding algorithms that I could reasonably construe as DP.

    If your x’s were sorted and you didn’t know the median was the answer, I could see computing partial sums from the right and left of a given index as DP-ish sub problems. The optimal solution then minimizes the sum of the right and left partial sums.

    But of course, I strongly dislike problems that say, “Solve X with Y”, especially when Y doesn’t really fit. “Solve X, you might want to consider using Y”, is a much better form of problem.

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

Sidebar

Related Questions

Wondering if anyone out there has ran into this before.... I'd like to use
I'm hoping someone can help me as I've been stuck on this problem for
This is bizarre, I was wondering if anyone could shed some light on why
UPDATE: For anyone else wondering about this, check out the comment at http://www.php.net/manual/en/function.imagecreatefromstring.php#31178 I
Possible Duplicate: Need help solving Project Euler problem 200 Similar to this question Project
Was wondering if anybody could help. Thanks so much! Problem : blog.example.com cool.example.com redirect
Hey guys - I'm stuck with this problem and im just wondering what the
I got stuck in this problem for an hour. I am thinking this is
I'm currently stuck on this problem. I've hooked into the method_missing function in a
I got stuck with this problem. I wrap two tables inside of a h:form.

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.