首页 > 其他分享 >comp2123 问题解答

comp2123 问题解答

时间:2023-05-28 17:44:54浏览次数:57  
标签:right point union top 问题解答 comp2123 rectangles rectangle


comp2123 Assignment 5 s1 2023
Problem 1. We want to design a divide and conquer algorithm for computing
the union of a collection of rectangles. The input rectangles are aligned with
the axes and they are all stabbed by the y-axis. Each rectangle is represented
by the coordinates of its top-left and bottom-right corners, and the union is
representation by a sequence of interior-disjoint rectangles listed from top to
bottom. We require that no two consecutive rectangles in the representation can
be merged into a single rectangle.
For example, the union of the three rectangles on the left leads to the union
represented by the four rectangles on the right:
y
union
y
In each case, the top-left and bottom-right corners of the rectangles in question have been highlighted for reference.
Here is another example where the union of two rectangles on the left leads
to the union represented by a single rectangle on the right1
:
y
union
y
The scaffold provided in Ed uses the following classes:
• Point: Represent a point on the plane with integer coordinates.
• Rectangle: Represents a single rectangle R. Supports membership queries
of the form does x ∈ R?
• Union: Represents the union U of a set of rectangles using a sequence of
disjoint rectangles in top-to-bottom order. Supports membership queries
of the form x ∈ U.
1Please note that in this second example, representing the union with two ore more rectangles
would be incorrect.
1
comp2123 Assignment 5 s1 2023
The scaffold provides the top level code for divided and conquer algorithms
to computing the union of a set of rectangles, but the merge step of each of these
algorithms is missing.
Using the scaffold provided in Ed, your task is to implement the missing
functions marked with a TODO note. Here is a non-exhaustive list of the main
functions:
• merge_unions(union_left, union_right): Compute the union of two Union
objects. You can assume the function will only be called by the divide and
conquer algorithm, so you only need to handle inputs that can arise from
the execution of the union divide and conquer algorithm. Your implementation should run in O(|union_le f t| + |union_right|) time.
• Rectangle.__init__( topleft_point , bottomright_point): Validate input and
throw ValueError if it doesn’t. Rectangle must intersect the y-axis and the
bottom-right corner must lie strictly to the right and strictly below the topleft corner.
• Rectangle.contains(point): Check if point lies on the rectangle.
• Union.contains(point): You can assume that the object is the result of some
union divide and conquer execution. Your implementation should run in
O(|union|) time.
WX:codehelp

标签:right,point,union,top,问题解答,comp2123,rectangles,rectangle
From: https://www.cnblogs.com/simpleyfc/p/17438554.html

相关文章

  • phpcms常见问题解答
    phpcms常见问题解答1.为什么phpcms首页幻灯片怎么显示不出来?答:需要设置文章的标题图片如果设置标题图片,则可以在首页以及栏目页以图片方式链接到文章。2.自定义phpcms的标签只能是全HTML?答:在自定义标签内容中可以插入html代码,也可以插入多个函数标签或者变量标签。插入函......
  • 2023年5月26日 问题解答
    为了解决问题一,我们可以使用调度算法来规划自动导引车的行动,以确保所有待加工任务能够顺利完成。首先,我们需要确定任务的处理顺序。根据表1中给出的加工时间,我们可以按照加工时间从小到大的顺序对任务进行排序。然后,我们可以使用一个列表来表示每台自动导引车的状态。初始时,所有......
  • 【HarmonyOS】【FAQ】HarmonyOS应用开发相关问题解答(一)
     【前提简介】本文档主要总结HarmonyOS开发过程中可能遇到的一些问题解答,主要围绕HarmonyOS展开,包括但不限于不同API版本HarmonyOS开发、UI组件、DevEcoStudio、Gitee示例代码等,并将持续更新哦。 【官方FAQ】【FAQ】HarmonyOS应用及服务开发常见问题汇总(官方总结,持续更新):ht......
  • 问题解答 | FMCW TDMA-MIMO毫米波雷达信号处理仿真
    本文编辑:@调皮连续波,保持关注调皮哥,获得更多雷达学习资料和建议!大家好,我是调皮哥,今天继续给大家分享干货,助力大家轻松、快乐、有方向地学习雷达。之前分享的文章:雷达仿真|FMCWTDMA-MIMO毫米波雷达信号处理仿真(可修改为DDMA-MIMO)当中,存在几个小问题(bug),具体如下:第十节:多普勒补偿”......
  • COMPSCI 589 问题解答
    COMPSCI589Homework4-Spring2023DueMay6,2023,11:55pmEasternTime1InstructionsThishomeworkassignmentconsistsofaprogrammingportion.Whileyoumaydiscussproblemswithyourpeers,youmustanswerthequestionsonyourownandimplementall......
  • Grid++Report 锐浪报表开发常见问题解答集锦
    Grid++Report锐浪报表开发常见问题解答集锦,锐浪报表报表对VBAccessC#Delphi支持都非常好,也可用于BS架构。Grid++Report适用于C/S报表与WEB报表(B/S报表)开发桌面报表与WEB报表共享相同的开发知识与资源,大大提高报表开发效率。另特别说明一点,在Access中使用Grid++Report锐浪......
  • COMP326问题解答
    COMP326Assignment2(15%ofthefinalmark)Due18thApril2023Pleasesubmityoursolutionselectronically(inPDFformat)onCanvasPleasebeawareoftheUniversityguidelinesonplagiarismandcollusion.Themarksforlatesubmissionswillbeaffectedin......
  • ECE 5101/CSE 5463 问题解答
    ECE5101/CSE5463,Spring2023Due:Apr.811:59pm,2023onCarmenHomeworkAssignment#4LateSubmissionNOTAcceptedHomeworkAssignment#41.(20points)InanunslottedALOHAsystem,thepacketarrivaltimesofallusersformaPoissonprocesshavingarate......
  • SEO常见问题解答:如何解决网站优化中遇到的难题和挑战
    SEO常见问题解答:如何解决网站优化中遇到的难题和挑战网站优化是提高网站在搜索引擎中排名和流量的重要手段,但是在优化过程中,往往会遇到各种难题和挑战,如何有效地解决这些问题,是每个网站运营者和SEO专家都需要掌握的技能。本文将针对一些常见的网站优化问题,给出一些解决方案和建议......
  • magento 问题解答 FQA
    1.IsthereawaybymysqltosetALLproductvisibilitytocatalog,search? 批量修改产品可见 openuptheeav_attributetableandfindtherowwhereattribute_code=visibility.Takenoteoftheattribute_id,mostlikelyitwillbe85.Alsotakenotetha......