Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Puzzle: The Ham Cheese Sandwich cut.

by BrowserUk (Patriarch)
on Nov 17, 2005 at 20:29 UTC ( [id://509555]=note: print w/replies, xml ) Need Help??


in reply to Puzzle: The Ham Cheese Sandwich cut.

Is this a "tree thing"?

You insert the points into a (Red-Black?) tree and they effectively sort themselves into the two required groups either side of the median which is ends up as the root node?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Puzzle: The Ham Cheese Sandwich cut.

Replies are listed 'Best First'.
Re^2: Puzzle: The Ham Cheese Sandwich cut.
by jeffguy (Sexton) on Nov 17, 2005 at 20:42 UTC
    I really doubt it because any point can have a median drawn through it. Remember, the median can go in any direction. For any point, you can find some angle to draw a line through that point that will separate all other points of that color into two equally-sized groups. So if it's a tree structure, it's not a standard one where divisions are made parallel to the axis of the graph.

      I've not yet convinced myself that this is soluble in the general case.

      In the 2D case, if all the points in both groups have one coordinate in common, and there are an odd number of points in each group or in the more general case of all the points lying on a straight line at any arbitrary angle.:

      +-----------+ +-----------+ +-----------+ | . | | | | . | | x | | | | . | | x | | | | . | | . | |.xx . x . | | x | | . | | | | x | | x | | | | x | +-----------+ +-----------+ +-----------+

      Unless you consider the line passing through all the points satisfies the criteria of having an equal number of each type of point on either side; ie. none?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Exactly. If all points lie on the same line, that line is the correct line.

        Btw, where I am so far, I may actually end up using some kind of (VERY nonstandard) tree to get from n^2 to n*lg(n). That would make you right :-)
Re^2: Puzzle: The Ham Cheese Sandwich cut.
by jeffguy (Sexton) on Nov 18, 2005 at 04:42 UTC
    (1b) I have an n*lg(n) solution for 2-D. Sorry, BrowserUK: I was SO wrong in saying no tree. My solution (which I have not coded) uses a PR quadtree. My solution is certainly not the only approach that will work.

    (1c) I have no idea (yet) how this might be brought up to O(n), nor do I have a clue (yet) how to prove it impossible.

    (2a) Also, while a PR quadtree can be used in 3D, my approach does not extend easily to 3D. More thought required.

    Question: For a puzzle, ought I post pseudocode/code on completion, or is it polite to instead leave the solution unposted, giving others the fun of solving it?

    Keep chuggin', guys! Nothing quite so rewarding as solving a tough puzzle!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://509555]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-20 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found