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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:10:11+00:00 2026-06-01T12:10:11+00:00

Assuming I have a large set of Coordinates such us (3,4) , (5,-6) ,

  • 0

Assuming I have a large set of Coordinates such us (3,4), (5,-6), etc., where x and y are integers; is it possible to order them using a BST?

How can I go about determining what should be on the left vs right node?

The reason why I’m looking at BST instead of simply using a list of coordinates is so that I can more efficiently (vs linear search) determine those coordinates that would be in the Moore neighborhood (Chebyshev distance 1) of another.

I’ve thought about alternating comparisons to x and y values; is that a good approach?

How else can I apply BST to this situation? Or is using BST untenable?

  • 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-01T12:10:13+00:00Added an answer on June 1, 2026 at 12:10 pm

    Despite the simplicity of the approach by aioobe to create a grid of cells (two dimensional array), it was a bit heavy handed/inefficient to store the state of all possible cells/coordinates especially when I may have cases where there is only have a handful of actual coordinates in a very large space (sparse array).

    Ultimately I realised using a BST is feasible (there are other approaches) and this is what I did to find Moore Neighbours efficiently using a balanced BST:

    1. Impose a ordinal relation on coordinates i.e. (x1,y1) > (x2,y2) => (x1 > x2) || (x1==x2 && y1 > y2)
    2. Sort list of coordinates by that relationship (to generate a balanced tree)
    3. Generate BST from sorted list recursively: insert median element as node, slice the list below and above the median and pass as parameter to recursive call for generating left and right sub-trees

    Then to search for the Moore Neighbours of a coordinate, I can then just look up/search for the 8 possible neighbour coordinates in the tree (as aioobe suggests) in O(log n).

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

Sidebar

Related Questions

I have a set of large text files that in total contain about 3
Assuming I have an open source web server or proxy I can enhance, let's
Assuming I have fonts installed which have the appropriate glyphs in them, is there
I would like to ask about Memory Overhead in java, I have a large
I have a large result set assembled in a parent/child relationship. I need to
I have a large set of real-world text that I need to pull words
I have a large file I'm uploading. The entire request can take more than
Assuming I have 2 large tables with well over 10 Million Rows in each
Assuming I have only the class name of a generic as a string in
Assuming I have three tables : TableA (key, value) TableB (key, value) TableC (key,

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.