Question: Problem 1 (20 points): Testing and Debugging 1. (10 points) Prof. Lumetta wrote a recursive function to sum over the values of all elements in
Problem 1 (20 points): Testing and Debugging 1. (10 points) Prof. Lumetta wrote a recursive function to sum over the values of all elements in a doubly linked list of elements (elt_ts) and the elements' children (and their childrens' children, and so forth). Unfortunately, the program doesn't compile. USING 20 OR FEWER WORDS. explain the problem and how one could fix it (you need not do so). (the bug) typedef struct elt_t elt_t; struct elt_ti elt_t* prev; elt_t* next; elt t children; // sentinel for a doubly-linked list of children int value; int total_value (elt_t* e) int v = 0; eltti one; for (one - e->prev; e ! - one; one - one->prev) { V + one->value + total value (Gone->children); return v; 2. (10 points) The function below is meant to determine whether a string s contains the character c, returning lif c appears within s and 0 if it does not. Sadly, the function has a bug. USING 15 WORDS OR FEWER, describe the bug. Then fix the program. (the bug) int has char (const chart s, char c) while (0 !- s) { if (c = *s) { return 1; s++; return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
