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

5. [15 points] For each of the function header blocks below, give an appropriate

ID: 3717778 • Letter: 5

Question

5. [15 points] For each of the function header blocks below, give an appropriate prototype and implementation. a) [6 points] In this question you may assume that implementations are provided for the fol- lowing functions, as used in the course: bool isTarget (: // returns true iff 3pi is on the end target void followSegment (boolk left. boolk right, bool& straight ); // follow the line to the nezt intersection, set left // right and straight indicating possible turns void turnLeft ): // turn left 90 degrees void turnRight ():// turn right 90 degrees Using these, you are to implement the following Follo w Route * Follow the given route s @params route -sequence of LR or S indicating the appropriate turn at each intersection in order lennumber of intersections in route . Greturns true if the 3pi ends on the target, false otherwise.

Explanation / Answer

Let me reply your first question.

here you need the function for respective route function.

bool followRoute(char *seq, int len)
{
while (len--)
{
if (*seq == 'L' && *(seq+1) == 'R')
{
seq++;
seq++;
}
else if (*seq == 'R' && *(seq+1) == 'L')
{
seq++;
seq++;
}
else if (*seq == L')
{
turnLeft();
seq++;
}
else
{
turnRight();
seq++;
}

}

if (istarget() == TRUE)
{
return TRUE;
}
else
{
return FALSE;
}
}

Thanks.

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