Starting with the tic-tac-toe program of Figure 12.4, draw a directed acyclic graph in which every clause
Question:
Starting with the tic-tac-toe program of Figure 12.4, draw a directed acyclic graph in which every clause is a node and an arc from A to B indicates that it is important, either for correctness or efficiency, that A come before B in the program. (Do not draw any other arcs.) Any topological sort of your graph should constitute an equally efficient version of the program. (Is the existing program one of them?)
Figure 12.4:
Transcribed Image Text:
printsquare (N) :- o(N), write(' o '). printsquare (N) :- x(N), write(' x '). printsquare (N) :- empty (N), write(' printboard :- printsquare(1), printsquare (2), printsquare (3), nl, '). printsquare (4), printsquare(5), printsquare(6), nl, printsquare (7), printsquare(8), printsquare (9), nl. clear :- retractall (x(_)), retractall(o(_)). % main goal: play clear, repeat, getmove, respond. respond :- ordered_line (A, B, C), o(A), o(B), o(C), % shouldn't ever happen! printboard, write('You won.'), nl. :- makemove, printboard, done. respond
Step by Step Answer:
This question has not been answered yet.
You can Ask your question!
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Directed Graphs a directed graph is a finite set of points, called nodes, and an associated set of paths or arcs, each connecting two nodes in a given direction. (See Fig. 3. 1 .6.) Think of the arcs...
-
Let G = (V, E) be a directed acyclic graph in which there is a vertex 0 V such that there exists a unique path from 0 to every vertex V. Prove that the undirected version of G forms a tree.
-
A path cover of a directed graph G = (V, E) is a set P of vertex-disjoint paths such that every vertex in V is included in exactly one path in P. Paths may start and end anywhere, and they may be of...
-
Suggest a systematic process that Daimler could have followed to increase the likelihood of merger success. Provide examples on how Daimler might have made such a process succeed.
-
For the channel in problem 7.21, the initial downstream water elevation is 10 ft. a house is to be built at a distance of x = 2640 ft upstream of the bridge. a) At what elevation should be house...
-
On January 1, the partners of Van, Bakel, and Cox (who share profits and losses in the ratio of 5:3:2, respectively) decide to terminate operations and liquidate their partnership. The trial balance...
-
The fixed budget performance report for the year ended 30 June 2025 for Motueka Mint is as follows. Required (a) Convert the fixed budget performance report prepared by Motueka Mint to a flexible...
-
The following refers to units processed in Sunflower Printings binding department in March. Prepare a physical flow reconciliation. Units of Percent of Product Conversion Added Beginning work in...
-
As a consultant, you have been tasked with determining whether the given borehole water supply is suitable for domestic use, in terms of hardness. As such, you carry out a chemical analysis on the...
-
You are the manager of a department store in Tokyo. Sales are subject to month-to-month variations, depending on the individual salesclerks efforts and other factors. A new salary-plus-bonus plan has...
-
Write Prolog rules to define a version of the member predicate that will generate all members of a list during backtracking, but without generating duplicates. Note that the cut and\+ based versions...
-
Prove that the tic-tac-toe strategy of Example 12.19 is optimal (wins against an imperfect opponent whenever possible, draws otherwise), or give a counterexample.
-
Calculate a sequence of 1-step-ahead forecasts for GDP growth rates based on the linear model (Exercise 7), the STAR model (Exercise 7), and the SETAR model (Exercise 8). Evaluate the forecasting...
-
The breaking strength for paper bags used in a grocery store is approximately normally distributed with a mean of 15 lb and a standard deviation of 2 lb. (a) What proportion of these bags has a...
-
The probability is .1 that a customer entering a food store will buy a can of coffee. If 1,000 customers enter the store, what is the minimum number of cans of coffee the store must have on hand to...
-
Suppose 15 % of the parts produced by a machine are defective. Use a normal approximation to the binomial distribution. What is the probability that a sample of 50 parts contains: (a) Five or more...
-
What penal regulations serve to check unlawful littering?
-
The following MINITAB output displays the cumulative distribution function curves of three normal distributions. Their mean and variance, respectively, are (0, .5), (0, 1), and (0, 2). Please compare...
-
Prepare any necessary adjusting entries at December 31, 2016, for Maxum Company's year-end financial statements for each of the following separate transactions and events. 1. Employees earn vacation...
-
How will relating product contribution margin s to the amount of the constrained resource they consume help a company maximize its profits?
-
In this exercise, we will look at the different ways capacity affects overall performance. In general, cache access time is proportional to capacity. Assume that main memory accesses take 70 ns and...
-
This exercise examines the impact of different cache designs, specifically comparing associative caches to the direct-mapped caches from Section 5.4. For these exercises, refer to the address stream...
-
Mean Time Between Failures (MTBF), Mean Time To Replacement (MTTR), and Mean Time To Failure (MTTF) are useful metrics for evaluating the reliability and availability of a storage resource. Explore...
-
Having a bit of trouble completing part of the code for my guessing game in java. Basically, I need to add the part of the code that will allow the user to choose how many games they wish to play....
-
Find all the "daffodil numbers" between 100 and 999 and output them. "Daffodil number" refers to a three-digit number, and the cube of each digit is exactly equal to the number itself. For example,...
-
Complete the program so that each cell of array sum contains the sum of the corresponding cells of valA and valB: class Exercise3 { public static void main(String[] args) { int[] valA = {13, -22, 82,...
Study smarter with the SolutionInn App