"Getting Started classic"--6.28

Source: Internet
Author: User

Greedy strategy: Select the disjoint interval problem.

Abstract Description: Give n intervals [Ai,bi], from which to select as many intervals as possible, so that these intervals can not intersect. Application of practical problems: This model is often examined as a carrier of the actual problem of the schedule.

Greedy Strategy Analysis:

The first thing we should understand is that if an interval C is a sub-range of another interval D, then obviously we will not go to the inter-constituency d.

So now let's analyze what might happen throughout the decision-making process.

Obviously we should analyze the adjacent interval. Give 3 intervals [A1,B1], [A2,B2], [A3,B3], and determine the relationship of the right end of the interval to B1<B2<B3, which allows us to determine a variable to parse another variable.

For A1>A2, this is the inclusion of what we said above.

For A1<A2, in this case, we will discuss the relationship between the interval [a3,b3] and the interval [A1,B1].

i) if the two do not intersect, obviously we are for interval 1 and interval 2, it is necessary to select the interval 1. Someone might ask why not discuss the relationship between interval 3 and interval 2? It is clear that the intersection of interval 3 and interval 2 must be discussed, otherwise the whole situation will not be discussed.

II) if the two intersect so that the three intervals have intersecting parts, obviously we still choose interval 1, because its b1 is the smallest, so in the subsequent decision (so the selection of the process of the interval based on BI from small to large sorting), can be as far as possible to make room for the other interval.

So we get greedy strategies, sort the bands for BI, select the first element of the linear table of the storage interval, and then delete the element and the interval that intersects the element.

"Getting Started classic"--6.28

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.