Question: #include imgUtils.c // This lets the driver code override the image size if it needs to. Make sure // you don't hard-code these values anywhere!

#include "imgUtils.c"

// This lets the driver code override the image size if it needs to. Make sure // you don't hard-code these values anywhere! #ifndef SIZEX #define SIZEX 512 #define SIZEY 512 #endif

/*---------------------------------------------------------------------------*/

/** * This struct contains one node of the linked list, which represents a single * command to the Turtle. It's field should include: * * - cmd : A char array of size 10 holding the command name * * - val : An integer that stores a parameter for the command (like forward, * backward and colour). * * - next : A pointer to a struct of the same type, this is used for the * linked list * * TODO: Complete this struct definition ****/

typedef struct cmdnode {

} CmdNode;

int countCommands(CmdNode *head) { /** * This function counts and returns the length of the linked list. It * requires list traversal. * * TODO: Implement this function */

return 0; }

/*---------------------------------------------------------------------------*/

CmdNode *insertCommand(CmdNode *head, CmdNode *new_CmdNode) { /** * This function inserts the node new_CmdNode *at the tail* of the linked * list. (You are adding a command at the end). * * If head == NULL, then the linked list is still empty. * * It returns a pointer to the head of the linked list with the new node * added into it. * * TODO: Implement this function */

return NULL; }

/*---------------------------------------------------------------------------*/

CmdNode *insertCommandBefore(CmdNode *head, CmdNode *new_CmdNode, int cmdNum) { /** * This function inserts a new node *before* a given Node in the linked list. * * 'cmdNum' is an integer that corresponds to the line number of a command * from the printCommandList() function. Your task is to insert new_CmdNode * *before* the corresponding node in the linked list. * * -------------------------------------------------------------------------- * * For instance, if your initial list was * * 0: penup * 1: forward 200 * 2: right * 3: forward 50 * * And you added "pendown" before cmdNum = 2, then you will have * * 0: penup * 1: forward 200 * 2: pendown * 3: right * 4: forward 50 * * -------------------------------------------------------------------------- * * If there is no command with the given cmdNum (cmdNum >= list size), * then print "Invalid Command Number. " to the screen and *do not* * insert the new node. * * Returns a pointer to the head of the linked list with the new node added * into it. * * TODO: Implement this function */

return NULL; }

/*---------------------------------------------------------------------------*/

void updateCommand(CmdNode *head, int cmdNum, char cmd[10], int val) { /** * This function updates a specific node in the linked list based on the * input parameters. * * 'cmdNum' is an integer that corresponds to the line number of a command * from the printCommandList() function. Your task is to update the 'cmd' and * 'val' fields of this node. * * If there is no command with the given cmdNum, then print * "Invalid Command Number. " to the screen, and if 'cmd' is not a correct * command, then print "Invalid command. ". In both these cases, do *not* * modify the list. * * TODO: Implement this function */

return; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!