Explanation of Solution
a.
Solution A: There exists a variable corresponding to every “n2” positions on the board.
Solution B: There is a variable corresponding to every knight.
Explanation of Solution
b.
Solution A: Each of the variables can be taken one of two values. The values can be taken are, “occupied” and “vacant”.
Solution B: Domain of each variable is the set of squares.
Explanation of Solution
c.
Solution A: Each and every pair of square separated by knight’s move constrained, such that both cannot be occupied. The entire set of squares is constrained, such that the number of occupied squares should be “k”.
Solution B: Each and every pair of knights is constrained, such that no two knights can be on the same square or on squares separated by a knight’s move. The solution B may be preferable because there is no global constraint, although the solution A has the smaller state space when “k” is large.
Explanation of Solution
d.
The solutions must be describing a complete-state formulation. This is because the use of local search
Solution C: Ensure that no attack at any time. Actions are to remove any knight, add a knight in any unattacked square, or move a knight to any unattacked square.
Solution D: allow attacks but try to get rid of them. Actions are to remove any knight, add a knight in any square, or move a knight to any square.
Want to see more full solutions like this?
Chapter 6 Solutions
Artificial Intelligence: A Modern Approach
- Consider eight points on the Cartesian two-dimensional x-y plane. a g C For each pair of vertices u and v, the weight of edge uv is the Euclidean (Pythagorean) distance between those two points. For example, dist(a, h) : V4? + 1? = /17 and dist(a, b) = v2? + 0² = 2. Because many pairs of points have identical distances (e.g. dist(h, c) V5), the above diagram has more than one minimum-weight spanning tree. dist(h, b) = dist(h, f) Determine the total number of minimum-weight spanning trees that exist in the above diagram. Clearly justify your answer.arrow_forwarda. Given n items, where each item has a weight and a value, and a knapsack that can carry at most W You are expected to fill in the knapsack with a subset of items in order to maximize the total value without exceeding the weight limit. For instance, if n = 6 and items = {(A, 10, 40), (B, 50, 30), (C, 40, 80), (D, 20, 60), (E, 40, 10), (F, 10, 60)} where each entry is represented as (itemIdi, weighti, valuei). Use greedy algorithm to solve the fractional knapsack problem. b. Given an array of n numbers, write a java or python program to find the k largest numbers using a comparison-based algorithm. We are not interested in the relative order of the k numbers and assuming that (i) k is a small constant (e.g., k = 5) independent of n, and (ii) k is a constant fraction of n (e.g., k = n/4). Provide the Big-Oh characterization of your algorithm.arrow_forwardCorrect answer will be upvoted else downvoted. There are n focuses on an endless plane. The I-th point has facilitates (xi,yi) to such an extent that xi>0 and yi>0. The directions are not really integer. In one maneuver you play out the accompanying activities: pick two focuses an and b (a≠b); move point a from (xa,ya) to either (xa+1,ya) or (xa,ya+1); move point b from (xb,yb) to either (xb+1,yb) or (xb,yb+1); eliminate focuses an and b. Notwithstanding, the move must be performed if there exists a line that goes through the new organizes of, another directions of b and (0,0). If not, the move can't be performed and the focuses stay at their unique directions (xa,ya) and (xb,yb), individually. Input The main line contains a solitary integer n (1≤n≤2⋅105) — the number of focuses. The I-th of the following n lines contains four integers ai,bi,ci,di (1≤ai,bi,ci,di≤109). The directions of the I-th point are xi=aibi and yi=cidi. Output :In the primary…arrow_forward
- Consider a maze represented by a matrix of m rows and n columns with obstacles (see the figure below). A cell with a value = -1 is an obstacle that cannot be overcome. The goal is to start from cell [0, 0] and reach the last cell [m-1, n-1]. This may be possible by taking several paths. Count the number of these paths. The movement is allowed from cells (i+ 1, j) and (i, j+ 1) only. -1 -1 Provide two solutions, one iterative and one recursive to the above problem.arrow_forwardYou and Alice and Bob are considering variants of the Pokemon problem. In the opti- mization problem we are looking for the minimum set of packs, and there are multiple ways to convert it to a decision problem (you probably used the standard method of adding a threshold variable k above). Alice considers the question "Is there a collection of packs of size 5 (or less) that includes one of every card in the set?". Bob considers the question "Is there a collection of packs of size [2] (or less) that includes one of every card in the set?". Are Alice and Bob's versions of the problem NP-complete? Either way, justify your answer with a proof.arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. You are given three positive (more prominent than nothing) integers c, d and x. You need to track down the number of sets of positive integers (a,b) with the end goal that balance c⋅lcm(a,b)−d⋅gcd(a,b)=x holds. Where lcm(a,b) is the most un-normal various of an and b and gcd(a,b) is the best normal divisor of an and b. Input The primary line contains one integer t (1≤t≤104) — the number of experiments. Each experiment comprises of one line containing three integer c, d and x (1≤c,d,x≤107). Output For each experiment, print one integer — the number of sets (a,b) to such an extent that the above uniformity holds.arrow_forward
- Hi please answer the following follow up questions as well, posted them as another question. Question 4 For the 9-tile soring problem, assume that you start from this initial state 7 2 4 5 6 8 3 1 The Goal State is: 1 2 3 4 5 6 7 8 The cost of moving any tile is 1. Let the heuristic function h(n) = number of misplaced tiles. For the shown configuration, there are four options for the next move: Move 5 to the right Move 6 to the left Move 2 down Move 3 up Each of these moves has a value f(n) = h(n) + g(n). If we choose to Move 5 to the right, then g(n) = 1. That is, it took us one step to reach this state from the initial state. h(n) = number of misplaced tiles. The misplaced tiles are {7,4,8,3,1}. So the number of misplaced tiles = h(n) = 5. If we choose to Move 6 to the left, g(n) is still = 1, but h(n) will change because the number of misplaced tiles is different. A* works by computing f(n) = h(n) + g(n) for each of these possible moves. Then it…arrow_forwardThis problem is taken from the delightful book "Problems for Mathematicians, Young and Old" by Paul R. Halmos. Suppose that 931 tennis players want to play an elimination tournament. That means: they pair up, at random, for each round; if the number of players before the round begins is odd, one of them, chosen at random, sits out that round. The winners of each round, and the odd one who sat it out (if there was an odd one), play in the next round, till, finally, there is only one winner, the champion. What is the total number of matches to be played altogether, in all the rounds of the tournament? Your answer: Hint: This is much simpler than you think. When you see the answer you will say "of course".arrow_forwardConsider the challenge of determining whether a witness questioned by a law enforcement agency is telling the truth. An innovative questioning system pegs two individuals against each other. A reliable witness can determine whether the other individual is telling the truth. However, an unreliable witness's testimony is questionable. Given all the possible outcomes from the given scenarios, we obtain the table below. This pairwise approach could then be applied to a larger pool of witnesses. Answer the following: 1) If at least half of the K witnesses are reliable, the number of pairwise tests needed is Θ(n). Show the recurrence relation that models the problem. Provide a solution using your favorite programming language, that solves the recurrence, using initial values entered by the user.arrow_forward
- Consider a billboard that consists of n vertical panels of width 1 and varying integer heights, hanged down and held by a horizontal roller from the top. The panel i has a height h For the objective of placing two banners, it is allowed to move each panel up by any integer length using the roller. Once the necessary moves are completed, you may place two banners completely inside of the panels. Based on the above description, what is the maximum total area that you can provide for the two posters? Output Print a single integer- the maximum total area the two posters can cover together. Example 1: 6 Input: Output: 18 Input The first line of input contains one integer n (1arrow_forwardYou are given a N*N maze with a rat placed at maze[0][0]. Find whether any path exist that rat can follow to reach its destination i.e. maze[N-1][N-1]. Rat can move in any direction ( left, right, up and down).Value of every cell in the maze can either be 0 or 1. Cells with value 0 are blocked means rat cannot enter into those cells and those with value 1 are open.Input FormatLine 1: Integer NNext N Lines: Each line will contain ith row elements (separated by space)Output Format :The output line contains true if any path exists for the rat to reach its destination otherwise print false.Sample Input 1 :31 0 11 0 11 1 1Sample Output 1 :trueSample Input 2 :31 0 11 0 10 1 1Sample Output 2 : false Solution: //// public class Solution { public static boolean ratInAMaze(int maze[][]){ int n = maze.length; int path[][] = new int[n][n]; return solveMaze(maze, 0, 0, path); } public static boolean solveMaze(int[][] maze, int i, int j, int[][] path) {//…arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. You are given two integers n and k. You ought to make a variety of n positive integers a1,a2,… ,a to such an extent that the total (a1+a2+⋯+an) is distinguishable by k and greatest component in an is least conceivable. What is the base conceivable most extreme component in a? Input The primary line contains a solitary integer t (1≤t≤1000) — the number of experiments. The solitary line of each experiment contains two integers n and k (1≤n≤109; 1≤k≤109). Output For each experiment, print one integer — the base conceivable most extreme component in cluster a to such an extent that the aggregate (a1+⋯+an) is distinct by k.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole