Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions