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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:18:25+00:00 2026-05-31T16:18:25+00:00

I have a grid of some width and height, where each cell can be

  • 0

I have a grid of some width and height, where each cell can be of three possible values (presented as white, green and red in this illustration):

illustration
(source: corexii.com)

You may select any number of green cells (marked blue on the following illustration), which covers all red cells (marked yellow) in a pre-determined square radius (here 2) around the selected cells:

illustration
(source: corexii.com)

The goal is to:

  • Cover as many red cells as possible
  • Using as few blue cells as possible
  • Do it as fast as possible

Anyone have any ideas for an algorithm?

I’m looking at a lot of theory, but what I’m most interested in is an approximation to do this quickly rather than accurately. A fast, reasonable result is preferable to computing the optimal one all day.

(The illustrations above may present the most normal distribution of these cells, but shouldn’t be assumed to resemble all possible distributions.)

  • 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-31T16:18:27+00:00Added an answer on May 31, 2026 at 4:18 pm

    This problem is a special case of the important NP-hard set cover problem. (The universe consists of the red cells, and each set consists of the red cells within the radius of one of the green cells.) The greedy algorithm gets within a log n factor of the optimal result.


    templatetypedef is right to point out that the fact that this problem is a special case of an NP-hard problem does not prove that it is in fact NP-hard too. That’s why I was careful in my phrasing above not to imply the latter. But being a special case of an NP-hard problem is a signal that shouldn’t be ignored: many special cases turn out on further investigation to be NP-hard themselves.

    So here’s a rough sketch that this problem is in fact NP-hard, by a reduction from VERTEX COVER FOR PLANAR GRAPHS OF DEGREE AT MOST FOUR.

    Suppose we have a planar graph of degree at most four, for example:

    Four vertices connected a-b-c-d-a and a-d

    Represent each vertex by a green square, and each edge by an alternating chain of red and green squares such that there are an even number of green squares, an odd number of red squares, and each green square will only cover the two red squares on either side if chosen. With a radius of 2, this is one possible representation of the graph:

    representation of original graph in terms of the covering problem

    In order to cover all the red squares, we need to choose at least half of the green squares on each chain corresponding to an edge the original graph. If we choose exactly half of the green squares on each chain, that leaves an uncovered red square at one end of each edge (and we can choose which end). So we get the minimum set of green squares if we can find the minimum set of vertices such that every edge is incident to a vertex in that set.

    In the example, we can cover the red squares using eight green squares if we pick vertices a and d:

    minimum cover with eight green squares selected and coloured blue

    And this corresponds to the minimum vertex cover in the original graph:

    minimum vertex cover

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

Sidebar

Related Questions

I have a grid of checkboxes where each cell has a fixed width, and
Here's the scenario I have a Grid with some TextBlock controls, each in a
I currently have a grid with 4 columns and 2 rows. Inside each cell
I have a fluid grid (in height and width). The LIs are always rectangular
Suppose I have a grid with some row definitions, and a child control in
I have some filter and one grid.And grid have some buttons like modify/edit.I am
Let's say I have some grid that looks like this _ _ _ _
I have a grid of rectangular cells covering a plane sitting at some distance
So I have a large grid of 289 rectangles (17x17) and I need some
We have a Telerik Grid (i.e. enhanced version of ASP.Net vanilla grid). On some

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.