Chapter 5: Problem 41
Modify the Backtracking algorithm for the \(0-1\) Knapsack problem (Algorithm 5.7) to produce a solution in a variable-length list.
Chapter 5: Problem 41
Modify the Backtracking algorithm for the \(0-1\) Knapsack problem (Algorithm 5.7) to produce a solution in a variable-length list.
All the tools & learning materials you need for study success - in one app.
Get started for freeList three more applications of backtracking.
Suppose we have a solution to the \(n\) -Queens problem instance in which \(n=4 .\) Can we extend this solution to find a solution to the problem instance in which \(n=5 ?\) Can we then use the solutions for \(n=4\) and \(n=5\) to construct a solution to the instance in which \(n=6\) and continue this dynamic programming approach to find a solution to any instance in which \(n>4 ?\) Justify your answer.
Use the Backtracking algorithm for the \(0-1\) Knapsack problem (Algorithm 5.7) to maximize the profit for the following problem instance. Show the actions step by step. $$\begin{array}{ccccc} i & p_{i} & w_{i} & \frac{p_{i}}{w_{i}} & \\ 1 & \$ 20 & 2 & 10 & \\ 2 & \$ 30 & 5 & 6 & \\ 3 & \$ 35 & 7 & 5 & W=19 \\ 4 & \$ 12 & 3 & 4 & \\ 5 & \$ 3 & 1 & 3 & \end{array}$$
Suppose that to color a graph properly we choose a starting vertex and a color to color as many vertices as possible. Then we select a new color and a new uncolored vertex to color as many more vertices as possible. We repeat this process until all the vertices of the graph are colored or all the colors are exhausted. Write an algorithm for this greedy approach to color a graph of \(n\) vertices. Analyze this algorithm and show the results using order notation.
Write a backtracking algorithm for the \(n\) -Queens problem that uses a version of procedure expand instead ofa version of procedure checknode.
What do you think about this solution?
We value your feedback to improve our textbook solutions.