The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Hello,tutor.I want to ask you a question about CSC 242 exercise question.Please you help me to respond this question.Thank you.
Â
Â
CSC242 Exercise Question: Write a recursive function get Tot () that returns the sum of a given list passed in as a
parameter that occurs in an arbitrarily nested list of numbers. If the list is empty, the function
returns 0. Otherwise the function returns the sum of all values in the list.
Note that your function must be recursive. You are not allowed to use any list methods in your
function other than indexing (e.g. lst [i] for some integer i, or len (). You are encouraged to
use the type () function. In writing the function you should not use any loops or global
variables, and you cannot change the number of parameters of the function or define any helper
functions. You may assume that the initial values given to the function are a list and your
function does not have to behave in any reasonable way when given something other than a list
as a parameter. The function must return and not print the count of the number of occurrences of
the string.
The following shows the behavior of the function on some sample parameters. Please remember
that these examples are just that. Your function must work correctly on all valid parameters, and
you may not make any assumptions about the number of nested in the parameter list.