# Difference between revisions of "Chapter 1"

Problems

1.1. Show that a + b can be less than min(a, b).

1.2. Show that a × b can be less than min(a, b).

1.3. Design/draw a road network with two points a and b such that the fastest route between a and b is not the shortest route.

1.4. Design/draw a road network with two points a and b such that the shortest route between a and b is not the route with the fewest turns.

1.5. The knapsack problem is as follows: given a set of integers S = {s1, s2. . . , sn}}, and a target number T, find a subset of S that adds up exactly to T. For example, there exists a subset within S = {1, 2, 5, 9, 10} that adds up to T = 22 but not T = 23.
Find counterexamples to each of the following algorithms for the knapsack problem. That is, give an S and T where the algorithm does not find a solution that leaves the knapsack completely full, even though a full-knapsack solution exists.
(a) Put the elements of S in the knapsack in left to right order if they fit, that is, the first-fit algorithm.
(b) Put the elements of S in the knapsack from smallest to largest, that is, the best-fit algorithm.
(c) Put the elements of S in the knapsack from largest to smallest.

1.6
1.7
1.8
1.9
1.10
1.11
1.12
1.13
1.14
1.15
1.16
1.17
1.18
1.19
1.20
1.21
1.22
1.23
1.24
1.25
1.26
1.27
1.28
1.29
1.30
1.31
1.32
1.33
1.34
1.35
1.36
1.37
1.38

Back to Problem Solutions
{"ft_lang_label":"__label__en","ft_lang_prob":0.8662401,"math_prob":0.98265475,"size":3337,"snap":"2021-43-2021-49","text_gpt3_token_len":1203,"char_repetition_ratio":0.17851785,"word_repetition_ratio":0.3721634,"special_character_ratio":0.45070422,"punctuation_ratio":0.23076923,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9865171,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-23T20:23:07Z\",\"WARC-Record-ID\":\"<urn:uuid:4c1a29b8-64c8-4412-9c60-fc7e4113119b>\",\"Content-Length\":\"41498\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6731fc8f-5c4b-43f5-abc1-a32563eedf91>\",\"WARC-Concurrent-To\":\"<urn:uuid:01ee887a-e053-4de0-98fd-c0ddf7ed0068>\",\"WARC-IP-Address\":\"54.187.141.137\",\"WARC-Target-URI\":\"https://www.algorist.com/algowiki/index.php?title=Chapter_1&diff=7&oldid=5\",\"WARC-Payload-Digest\":\"sha1:GHR246Y6EUWW5ZNZNQVXULMGUW2WBYAW\",\"WARC-Block-Digest\":\"sha1:T7LXZM4WK4OGEMVB525T6B6SS6PWQFBU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585768.3_warc_CC-MAIN-20211023193319-20211023223319-00052.warc.gz\"}"}