jackfrued / jackfrued/Python-100-Days

关于16-20中贪心算法偷东西例子的错误

Open
#337 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
187k
Forks
55.8k
PR merge metrics
No merged PRs in 30d

Description

您这个例子是无法保证通过贪心算法得到最优解的,一个反例就是:
(以下1-3列分别表示商品名、价格、重量)
商品1 60 10
商品2 100 20
商品3 120 30
背包重量上限为50
(该例子出自《算法导论》)

不难验证,您的算法无法得到最优解
0-1背包问题是不能用贪心算法的

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the lesson covering the greedy algorithm example in sections 16–20 and read the surrounding explanation. Verify the reported counterexample and update the example or its explanation so the 0-1 knapsack limitation is accurate.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
content, documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.