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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:08:44+00:00 2026-06-05T14:08:44+00:00

Let P be a simple, but not necessarily convex, polygon and q an arbitrary

  • 0

Let P be a simple, but not necessarily convex, polygon and q an arbitrary point not necessarily in P.

Design an efficient algorithm to find a line segment originating from q that intersects the maximum number of edges of P.

In other words, if standing at point q, in what direction should you aim a gun so the bullet will go through the largest number of walls?

A bullet through a vertex of P gets credit for only one wall.

An O(n log n) algorithm is possible. n is the number of vertices or edges, as it is a polygon, number of edges roughly equals to number of vertices.

this is the same as this
this question however I was not able to understand the answer, more specifically the answer did not seem to involve q, also the head and butts thing was not clear as each point on a polygon would be a head and a butt as each point is attached to two edges, if that makes sense.
Thanks

  • 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-05T14:08:46+00:00Added an answer on June 5, 2026 at 2:08 pm

    So any optimal answer that does not intersect the polygon near any vertex will have a fellow optimal answer that nearly intersects a vertex of the polygon.

    That is, if you have a line going through 10 “walls” and it is not near a vertex you can translate it in some direction towards a vertex while still keeping 10 walls intersected.

    By this reasoning you only have to search for solutions that pass near verticies.

    So sort the verticies (nlogn) and then search each possible line segment that nearly intersects one (3n). You can do this without recalculating the full set of intersections on each candidate line, because as the line moves from one vertex to another it either adds or loses 2 walls (or remains the same). You can track this incremental change.at constant time at each step.

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

Sidebar

Related Questions

Here is an interesting exercise: Let P be a simple, but not necessarily convex,
This should be very simple, but I'm blocking on this.... Let's say, for the
What is good design in this simple case: Let's say I have a base
I belive my question is rather simple but somehow I'm not reaching any success.
A simple example: Let's say I have one alias being sourced somewhere as: alias
Before you start laughing at such a simple question let me explain: I am
I found out the next issue in this simple code: let () = print_endline
Let's create a simple tuple, dictionary and function. >>> tup = (7, 3) >>>
Let me describe a simple use-case: Running all tests in our project may take
Let's say I'm making a fairly simple web application using JAVA EE specs (I've

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.