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

  • Home
  • SEARCH
  • 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 3983932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:42:30+00:00 2026-05-20T05:42:30+00:00

Can someone please explain to me why the recursive part of this algorithm has

  • 0

Can someone please explain to me why the recursive part of this algorithm has the runtime

T(n) = {O(1), if n ≤ 3;
{Tf(n/2) + Tc(n/2) + O(n), if n > 3.

->where Tf(n/2) represents the floor function of T(n/2) and Tc(n/2) represents the the ceilling function????

The algorithm is called Shamos and the main steps are:

  1. If n ≤ 3 find the closest points by brute force and stop.
  2. Find a vertical line V such that divides the input set into two disjoint subsets PL and PR of size
    as equal as possible . Points to the left or on the line
    belong PL and points to the right or on the line belong to PR. No point belongs to both since
    the sets are disjoint.
  3. Recursively find the distance δL of a closest pair of points in PL and the distance δR of a closest
    pair in PR.
  4. Let δ = min(δL, δR). The distance of a pair of closest points in the input set P is either that of
    the points found in the recursive step (i.e., δ) or consists of the distance between a point in PL
    and a point in PR.

    (a) The only candidate points one from PL and one from PR must be in a vertical strip consisting
    of a line at distance δ to the left of the line V and a line at distance δ to the right of V

    (b) Let YV be an array of the points within the strip sorted by non-decreasing y coordinate
    (i.e., if i ≤ j then YV [i] ≤ YV [j]).

    (c) Starting with the first point in YV and stepping trough all except the last, check the distance
    of this point with the next 7 points (or any that are left if there are not as many as 7). If a
    pair is found with distance strictly less than δ then assign this distance to δ.

  5. Return δ.
    Thank you in advance.

  • 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-20T05:42:31+00:00Added an answer on May 20, 2026 at 5:42 am

    T(c(n/2)) and T(f(n/2)) describe how much time it takes to call the algorithm recursively on the left and right groups, respectively, since half of the points have been placed in each group.

    O(n) comes from the tricky part of the algorithm: after the recursive calls, we have found δ, namely the distance between the closest pair of points either in the left group or in the right group. Now we want to look for pairs consisting of one point from the left group and one point from the right group. Of course, there is little use in looking at points that are further away than δ from the middle line. However, it could still be that all points are within δ of the middle line, so it looks like we risk having to compare n^2 point pairs. The important observation now is that precisely because we know that in each group, no pair of points is closer than δ, we know that there is a small, constant worst-case limit to how many points from the right group we need to look at for each pair in the left group. So if we can only get our points sorted on their y-coordinates, we can find the closest pair in linear time. It’s possible to obtain this sorted list in linear time due to the way the list is passed between the recursive calls, but the details escape me (feel free to fill in, anyone).

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

Sidebar

Related Questions

No related questions found

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.