Algorithm Design and Analysis: Lecturer: M. Sohaib Ajmal
Algorithm Design and Analysis: Lecturer: M. Sohaib Ajmal
A B C D
4
Move right 3 squares
How do I get Minion Stuart to move to D1 then
to D4?
A B C D
4
Move right 3 squares
Move down 3 squares
How do I get Minion Stuart to move to D1 then
to D4, then move to A4 and finally to A1?
A B C D
Creating websites
2
Extension = Can
you add a
‘question to say if
3 the minion
reaches a
banana?
4
Algorithm Solution written in
pseudocode
1. Move right 2 squares
A B C D 2. Pick up banana
3. Move right 1 square
1 4. Move down 1 square
5. Pick up banana
2
6. Move left 2 squares
7. Pick up banana
3
8. Move down 1 square
9. Move right 1 square
4
10. Pick up banana
11. Move down 1 square
12. Move left 2 squares
13. Pick up banana
Can you ask a question?
When we think about the way Minion Stuart
moves across could we ask a question as he
moves from one side to the other?
A B C D
4
Possible algorithm in
pseudocode
1. Move right 3
A B C D squares
2. IF Minion reaches
1
a banana
2 a. THEN pick it up
3. IF Minion reaches
3
an apple
4 a. THEN leave it
This would continue
This form of pseudocode would help a game
designer plan out the code they would need to to cover the whole
write to create it.
board
Finally