Subsets and problems of algorithm two

Source: Internet
Author: User

What are subsets and numeric issues?

Problem analysis, simply said that there is n number in this n number of selected number of the number to make these several numbers and M.

The way to solve the problem, using backtracking.

Finally form a two-fork tree

On the left there is this number, and the right son is not this number.

Using backtracking, one of the calculations, the time is too long.

Use certain conditions to shorten the time.

The premise is to sort all the numbers in a non-descending order, and then do the following.

A limit function that shrinks the set of possible solutions. Some can not produce the feasible solution directly to exclude.

∑w (i) X (i) +∑w (i) >=m

∑w (i) X (i) +w (k+1) >m

If you add a number k, if the number of k-1 and less than M, plus K is less than M but plus the next number of K is greater than M, then the number k is not calculated, directly excluded.

Subsets and problems of algorithm two

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.