发现包含了所有的矩形面积最小 [英] find smallest area that contains all the rectangles

查看:230
本文介绍了发现包含了所有的矩形面积最小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个面试问题。
我们给出了不同的矩形尺寸,我们必须找出矩形的面积(最小),可以附上所有的人?矩形也可以旋转。

This is an interview question.
We are given dimensions of various rectangles, we have to find out the area(minimum) of rectangle that can enclose all of them? rectangles can be rotated also .

test case:-
input:
3   //number of rectangles
8 8
4 3
3 4

output:
88

11x8:
+ - - - - - - + + - +
|             | |   |
|             | |   |
|             | + - +
|             | + - +
|             | |   |
|             | |   |
+ - - - - - - + + - +

我看着面前<一问过类似的问题href="http://stackoverflow.com/questions/5371104/fitting-rectangles-in-the-smallest-possible-area">fitting在尽可能小的区域的
矩形 上述方法看起来在所有的可能性,旋转和确定最小超过在所有的布局情况下,所有这些可能性。
我们不能为基础的算法中,我们发现长方形的面积之和,然后再寻找最大长度,宽度是多少?

i looked at a similar question asked before fitting rectangles in the smallest possible area
the above approach looks at all possibilities ,rotations, and determine the minimum over all such possibilities in all layout cases.
can't we base an algorithm in which we find the sum of area of rectangles first and then look for max length ,width?

推荐答案

没有绝对的解决了这个问题,但也有一些近似解,你可以看到其中的一些<一href="http://www.$c$cproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu">here.

There is no absolute solution to this problem, but there are several approximate solutions, you can read about some of them here.

这篇关于发现包含了所有的矩形面积最小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆