# Chapter 1

Revision as of 19:31, 23 August 2020 by Algowikiadmin (talk | contribs)

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.

- (a) Put the elements of

- (b) Put the elements of
*S*in the knapsack from smallest to largest, that is, the best-fit algorithm.

- (b) Put the elements of

- (c) Put the elements of
*S*in the knapsack from largest to smallest.

- (c) Put the elements of

- 1.6. The
*set cover problem*is as follows: given a set*S*of subsets*S1, . . . , Sm*of the universal set*U*= {1, ...,*n*}, find the smallest subset of subsets*T ⊆ S*such that*∪ti∈T ti*=*U*. For example, consider the subsets*S1*= {1, 3, 5},*S2*= {2, 4},*S3*= {1, 4}, and*S4*= {2, 5}. The set cover of {1, . . . , 5} would then be*S1*and*S2*. - Find a counterexample for the following algorithm: Select the largest subset for the cover, and then delete all its elements from the universal set. Repeat by adding the subset containing the largest number of uncovered elements until all are covered.

- 1.8

- 1.10

- 1.12

- 1.14

- 1.16

- 1.18

- 1.20

- 1.22

- 1.24

- 1.26

- 1.28

- 1.30

- 1.32

- 1.34

- 1.36

- 1.38

Back to Chapter List