Question: You must assign the grades for a programming class. The class is studying recursion, and students have been given this simple assignment: Write a recursive

You must assign the grades for a programming class. The class is studying recursion, and students have been given this simple assignment: Write a recursive function SumSquares that takes a pointer to a linked list of integer elements and returns the sum of the squares of the elements.

Example:

list Data 5 2 3 1

SumSquares(listPtr) yields (5 * 5) + (2 * 2) + (3 * 3) + (1 * 1)
= 39 Assume that the list is not empty.
You have received quite a variety of solutions. Grade the functions that follow, marking errors where you see them.

image text in transcribed

list Data 5 2 3 1

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

struct ListNode int value ListNode next ... View full answer

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 Programming Language Pragmatics Questions!