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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:27:28+00:00 2026-05-13T06:27:28+00:00

Algorithm Consider this layout: +————-+ | | | | | +–+ | | |##|

  • 0

Algorithm

Consider this layout:

+-------------+
|             |
|             |
|   +--+      |
|   |##|      |
|   |##|      |
|   +--+------+
|      |######|
|      |######|
+------+------+

The black part is the occupied space. Now I need an algorithm that returns the largest remaining rectangular spaces. (Ordered from top to bottom, left to right.)

Like this:

1                 2          3            4
+-------------+   +----      -------+
|#############|   |###        ######|
|#############|   |###        ######|
|   +--+      |   |###+      +######|
                  |###|      |######|
                  |###|      |######|
                  |###+      +------|     |   +--+
                  |###                    |######|
                  |###                    |######|
                  +----                   +------+

Input

The width and height of the enclosing container. (A page in my code.)

A list of already occupied rectangles. They can be in any form that you like. E.g. (x,y,width,height) or (x1,y1,x2,y2)

I’m dealing with floats, therefore a mathematical solution would be preferred.

  • 1 1 Answer
  • 1 View
  • 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-13T06:27:28+00:00Added an answer on May 13, 2026 at 6:27 am

    From your example it appears that you aren’t asking to exclude overlap (e.g. 1 and 2 have the top-left segment in common), so perhaps this will suit your needs:

    1. Divide the space into rectangles based on the corners identified by the occupied spaces.

    2. Form the “basic rectangles” by extending line segments from those corners to the edges of the entire space.

    3. Using any systematic order (e.g. top-to-bottom, left-to-right):

      3.1. Select a basic rectangle and extend it as far as possible with other basic rectangles that have a side in common.

      3.2. Form the set of all (unique) such extended rectangles.

    Note that this searches/builds based on the “basic rectangles” from step 2, and not point-by-point throughout the entire space, so the performance should be much better.

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

Sidebar

Related Questions

Consider an algorithm that needs to determine if a string contains any characters outside
this is my algorithm that I have written it with my friends (which are
EDIT: This isn't as trivial as you think. Consider the fact that each addition
I need to solve this algorithm problem. In the diagram, there are many rows
Consider this example: #include <algorithm> #include <iostream> int main() { std::string str = abcde4fghijk4l5mnopqrs6t8uvwxyz;
Consider the current algorithm below that iterates through a GridView 's rows to find
Possible Duplicate: Image comparison algorithm So basically i need to write a program that
In Multi-Paxos algorithm, consider this message flow from the viewpoint of an acceptor: receive:
In Algorithm Design Manual , there is such an excise 4-26 Consider the problem
Consider the following code: #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <algorithm>

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.