Results 1 to 4 of 4

- 05-25-2013, 06:42 AM #1Member
- Join Date
- May 2013
- Posts
- 1

- Rep Power
- 0

## hello ,have a good day all , i need some answers of these questions...

1. Operator effect definition:

oi,j ((a1 , a2 , . . . , a12 )) = (b1 , b2 , . . . , b12 )

k = 1, 2, . . . , 12

if (a1 , a2 , . . . , a12 ) ∈ dom(oi,j )

bk =

ak + j

ak + 120

if ∃l(al > ak ) ∨ (ak + ai = 0)

otherwise

Exercise 4. Create the Java implementation for the function above as a body of a void function!

We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1], a[2],

. . ., a[12], and b1 , b2 , . . . , b12 are integers, and they are accessible in the function body as b[1], b[2], . . .,

b[12].

answer :

2.

Set of operators:

O = {o1,2 , o1,3 , o2,1 , o2,3 , o3,1 , o3,2 }

Domain of operators:

dom(oi,j ) = {(a1 , a2 , . . . , a12 ) ∈ N12 | ∀k((k = j) ⊃ (ak + i > aj )) ∧ ∃k∃l(a1 = ak ∗ al )}

Exercise 3. Create the Java implementation for the preconditions above as a body of a boolean

function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],

a[2], . . ., a[12].

answer :

3.

Set of goal states:

G = {(a1 , a2 , . . . , a12 ) ∈ N12 | ∀i∃j((ai + aj > 20) ⊃ (ai ∗ aj < 200))}

Exercise 2. Create the Java implementation for the goal condition above as a body of a boolean

function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],

a[2], . . ., a[12]

answer :

4.

∀i(∃j((aj < ai ) ∨ (aj = 1000)) ⊃ (ai > 0) ∨ ∃j(aj = 50))

where i ∈ {1, 2, . . . , 6} and j ∈ {1, 2, . . . , 6}

Exercise 1. Create the Java implementation for the formula above as a body of a boolean

function! We suppose that a1 , a2 , . . . , a6 are integers, and they are accessible in the function body as a[1],

a[2], . . ., a[6].

answer :

5.

1.all i exists j a[i] > a[j] or a[1] = a[4]

all i ( exists j ( (a[j] < a[i]) or not (a[j] = 1000) ) implies ( a[i] > 0 or exists j ( a[j] = 50 ) ) )

implementation in java :

------------------------------------------------------------------------------------------------

Complete the Java implementation of the Breadth-first search

Exercise 1. Initialize the database.

Exercise 2. Construct the solution as an operator list.

Exercise 3. Complete the code of the extension.

❜

public interface Problem {

State startState();

Collection<Operator> operators();

}

public interface State {

boolean isGoal();

}

public interface Operator {

boolean isApplicable(State s);

State apply(State s);

❜

}

public abstract class Solver {

private static class Node {

State state;

Operator creator;

Node parent;

int deep;

public Node(State state, Operator op, Node parent ) {

this.deep = parent == null ? 0 : parent.deep + 1;

this.creator = op;

this.parent = parent;

this.state = state;

}

❜

}

public List<Operator> run(Problem p) {

LinkedList<Node> closedNodes = new LinkedList<Node>();

LinkedList<Node> openNodes = new LinkedList<Node>();

/* Exercise 1: Initialize the database. */

while ( ! openNodes.isEmpty() ) {

Node node = openNodes.removeFirst();

if ( node.state.isGoal() ) {

LinkedList<Operator> solution = new LinkedList<Operator>();

/* Exercise 2: Construct the solution as an operator list. */

return solution;

}

closedNodes.add(node);

for ( Operator op : p.operators() ) {

if ( op.isApplicable(node.state) ) {

State newState = op.apply(node.state);

/* Exercise 3: Complete the code of the extension

* (use the search function below when necessary). */

}

}

}

return null;

}

private static Node search(List<Node> nodeList, State state) {

for ( Node node : nodeList )

if ( state.equals(node.state) )

return node;

return null;

}

}

- 05-25-2013, 08:18 AM #2
## Re: hello ,have a good day all , i need some answers of these questions...

You understand that shamelessly dumping your homework in here will get you nothing? What is this, Rent-a-coder.com?

There are three things you can do though:

1) Start writing your own code and show us the problems you have, errormessages etc. It's an exercise for a reason.

2) Drop the CS-class and pick up a Management class, because you are good in delegating your work to others.

3) Do nothing and practice the line: "Do you want fries with that?"

- 05-25-2013, 12:54 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,414
- Blog Entries
- 7

- Rep Power
- 25

## Re: hello ,have a good day all , i need some answers of these questions...

Being a math person, I'm quite used to all that notational gobbledygook, but this is beyond me ...

kind regards,

JosBuild a wall around Donald Trump; I'll pay for it.

- 05-25-2013, 02:01 PM #4
## Re: hello ,have a good day all , i need some answers of these questions...

It reminds me of a Java book I bought some 15 years ago, written by Leen Ammeraal, published by Academic Service. He explained basic operations on primitives in applets in chapter one. The exercise after chapter one was to write a rotating chessboard. Needless to say I bought myself another book...

## Bookmarks