Advertisements
Advertisements
Question
Initially, farmer, goat, grass, wolf = L, L, L, L, and the farmer crosses the river with a goat. Model the action with an assignment statement.
Answer in Brief
Solution
- — farmer, goat,grass,wolf = L,L,L,L.
- Farmer,goat: = R,R
- – farmer,goat,grass,wolf = R,R,L,L
- – farmer: = L
- — farmer,goat,grass,wolf = L,R,L,L
- farmer,grass: = R,R
- — farmer,goat,grass,wolf = R,R,R,L
- farmer,goat: = L,L
- — farmer,goat,grass, wolf = L,L,R,L
- farmer, wolf: = R,R
- — farmer,goat,grass, wolf = R,L,R,R
- farmer: = L
- — farmer,goat,grass,wolf = L,L,R,R
- farmer, goat: = R,R
- — farmer,goat,grass,wolf = R,R,R,R
shaalaa.com
Abstraction
Is there an error in this question or solution?
APPEARS IN
RELATED QUESTIONS
If i = 5 before the assignment i := i - 1 after the assignment, the value of i is ______
If 0 < i before the assignment i := i - 1 after the assignment, we can conclude that ______
What is abstraction?
What is the form and meaning of the assignment statement?
What is the difference between the assignment operator and the equality operator?