CLRS
CLRS copied to clipboard
wrong solution to 16.1-5
Hi, First of all thanks for this project, it's very useful!
Now, I believe the proposed O(nlgn) solution to 16.1-5 (https://walkccc.me/CLRS/Chap16/16.1/) is wrong. Let's consider three activities: a1={s=1, f=3, v=2}, a2={s=2, f=5, v=4}, a3={s=3, f=6, v=3}. The proposed solution will:
- add a1 // this is just the start
- remove a1 and add a2. // they overlap and a2.v > a1.v
- will not add a3 // a2 and a3 overlap, a2.v > a3.v
It will give a result
with total value = 4. But the correct solution should be <a1, a3>, total value = 5. Regards, Andrzej