算法分析与设计——区间调度问题

本文介绍了区间调度问题,包括无权和加权两种情况。针对无权区间调度,提出了贪婪算法,选择最早结束时间的请求。对于加权区间调度,通过动态规划求解最大权重的非重叠请求子集,时间复杂度降低到O(nlogn)。此外,还讨论了算法的证明和实现细节。
摘要由CSDN通过智能技术生成

Very similar problems can have very different complexity.

  • P: class of problems solvable in polynomial time.
  • NP: class of problems verifiable in polynomial time.
  • NP-complete: problems is in NP and as hard as any problem in NP.
    If any NP-complete problem can be solved in polynomial time, then every problem in NP has a polynomial time solution.
    NP-complete problem is a subproblem of NP problem.
    只可以用非确定性方法才能在多项式时间求解1

Interval Scheduling

Request 1, 2, … , n, single resource
Goal: Select a compatible subset of requests of maximum size.
Claim: We can solve this using a greedy algorithm.
A greedy algorithm is a myopic algorithm that processes the input one piece at a time with no apprent look ahead.

Greedy Interval Scheduling

  1. Use a simple rule to select a request i i i.
  2. Reject all requests that are incompatible with i i i.
  3. Repeat until all requests are processed.

Rule: select request with earliest finish time, i.e., minimum f ( i ) f(i) f(i).

Prove

Skip

Weighted Interval Scheduling

Each request i i i has a weight w ( i ) w(i) w(i). Schedule subset of requests that are non-overlapping with maximum weight.

Dynamic Programming

We can define our subproblems as
R x = { j ∈ R ∣ s ( j ) ≥ x } \begin{aligned} R^x = \{j \in R|s(j) \geq x\} \end{aligned} Rx={ jRs(j)x}
​ Here, R R R is the set of all requests.
​ If we set x = f ( i ) x=f(i) x=f(i), then R x R^x Rx is the set of requests later than request i i i.
​ Total number of sub-problems = n = n =n (one for each request).
​ Only need to solve each sub-problem once and memorize.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值