Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This assignment requires pseudocode. You may use only actions provided in the as

ID: 3902507 • Letter: T

Question

This assignment requires pseudocode.

You may use only actions provided in the assignment:

move forward 1 unit,

turn left,

turn right.

sense the ground green or red.

You may indicate repeating any one or multiple actions above.

Note, if condition doesn't automatically repeat anything, it is a one time matter.

To repeat actions under certain condition, use Repeat when ... (Repeat if ...)

Note, move left (or move right) is not provided. To move left, 2 steps are involved: turn left, move forward.

Write an algorithm that allows a robot to mow a rectangular lawn, provided it has been placed in a corner, like this: The robot (marked as R) can: Move forward by one unit. Turn left or right. Sense the color of the ground one unit in front of it.

Explanation / Answer

The algorithm is as follows:

Repeat :
    Repeat till sense a red colour
         Move forward by one unit
    turn right
    move forward by one unit
    turn right
    sense the colour
        if red
           break from the loop
    Repeat till sense a red colour
         Move forward by one unit
    turn left
    move forward by one unit
    turn left
    sense the colour
        if red
           break from the loop   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote