联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2019-09-10 11:26

Computer Science 320SC – (2019)

Programming Assignment 3

Due: Saturday, September 14th (11:57pm)

Requirements

This assignment requires you to write three efficient algorithms that processes intervals. At least two

of them should be implemented via some type of greedy algorithm. It is worth 5% of your total course

marks.

All three programs have the same input and output format. The input will begin with an integer

n ≤ 1000 denoting how many test cases. This is followed by n lines of an even number 2m of whitespace

separated integers:

a1 b2 a2 b2 a3 b3 . . . am bm

Each pairs [ai

, bi

] denotes a closed interval where it is guaranteed that ai ≤ bi for 1 ≤ i ≤ m. The

output will be a single integer per line denoting the answer to the following questions.

Problem 1:

Determine the maximum number of non-overlapping intervals.

Problem 2:

Find the maximum number of intervals that overlap at a single point (on x-axis).

Problem 3:

Compute the largest contiguous interval obtained by taking a union of some of the input intervals.

Sample Input:

Submission

These problem requirements will be worth 2, 2 and 1 marks, respectively, on the computer science

automarker https://www.automarker.cs.auckland.ac.nz/. For this assignment you can use any

language supported on the automarker and can submit up to 8 times for each problem before occuring

a 20% penalty.

1


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp