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

This question tests your ability to construct algorithms. Your answers can be in

ID: 3815441 • Letter: T

Question

This question tests your ability to construct algorithms. Your answers can be in English, pseudo-code or Python. This question requires you to consider how you might design algorithms to instruct a "turtle" (a small graphical sprite which can be moved around the screen under program control) to perform useful tasks. (a) How would you tell the turtle to move in a complete circle? (b) Imagine that your turtle is now equipped with sensors which can tell if they are over a white pixel or a black pixel (see the screenshot below). Your mission is to move around the screen and find a black pixel. How would you tell the turtle to do this? (c) The screenshot below shows that the turtle is placed on a track. Each of the three dots on the turtle is one of it's sensors. In the picture, the turtle is facing towards the bottom of the screen, one sensor is over a black pixel and two are over white pixels (see the diagram on the bottom right of the screenshot-note that this shows the sensors as the turtle faces towards the top of the screen). The turtle is currently at the start of the track. Describe (in English) how you would instruct the turtle to move around the track, given that it can move forwards and backwards, rotate left and right and tell whether it's sensors are over black or white pixels.

Explanation / Answer

Hello,

Below are the algorithms in english for the three cases mentioned in the question:-

Algorithms for first case :The name turtle_traverse is used for algorithm1

assumptions:-

//assume that the path of circle consists of n points starting from n1, n2, n3, n4….n1

//the turtle is at point n1

Begin algorithm turtle_traverse

Step1:-Turtle is at point n1

Step 2:- while (turtle reaches point n1 again)

                      TURTLE TRAVERSE ALL THE POINTS        n2, n3, n4…..

Step 3:=Turtle is at point n1.

Step4:-Turtle stops

End algorithm turtle_traverse

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

Algorithm for second case:The name turtle_traverse_clakpixel is used for algorithm2

Assumption:-

//assume that the path of circle consists of n points starting from n1, n2, n3, n4….n1

//the turtle is at point n1

Begin algorithm turtle_traverse_blackpixel               

Step1:-Turtle is at point n1;

Step 2:- while (turtle reaches point n1 again)

                      Traverse through succeeding point

                      Sense pixel

                      If pixel == black

                         {          

                             Tell the pixel

                        }

Step 3:=Turtle is at point n1.

Step4:-Turtle stops

End algorithm turtle_traverse_blackpixel

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

Algorithm for third case:The name turtle_traverse_findpixel is used for algorithm3

Assumptions:-

//assume that the track contains point t1, t2, t3….t1

//assume that sensors are s1, s2, s3

Begin algorithm turtle_traverse_findpixel

   Step1:-Turtle is at point t1;

    Step 2:- while (turtle reaches point t1 again)

                     Move forward through succeeding point

                      Sense pixel

                      Tell pixel colour sensed in s1, s2, s3

    Step 3:- turtle is at point t1      

    Step4:-Turtle stops

   End algorithm turtle_traverse_findpixel

=================================================================================

Please let me know in case any additional info is required.

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