Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NO FOR LOOPS Write a recursive function findMaxLenSet) that takes an arbitrarily nested list as a parameter and returns the length of the biggest set

NO FOR LOOPS

image text in transcribed

Write a recursive function findMaxLenSet) that takes an arbitrarily nested list as a parameter and returns the length of the biggest set found in the list. If the list is empty or the list does not contain any sets, then the function returns 0. Recall that you can determine whether an item is a list by writing type(item)-list and whether an item is a set by writing type(item) -set. The only list functions you are allowed to use are leno. max), indexing (Ist[i] for an integer i), or slicing (lst[i:j] for integers i and j). Note that although you are allowed to use the max) function, the function must use recursion as the primary problem-solving tool. You will know you're on the wrong track if you ever try to apply max() to the entire list. Instead it should be used to determine which of a small number of values that were computed using recursion should be returned. You should assume that the parameter provided to the function is a list, and the function is not required to do anything sensible when given something other than a list. The function should not alter the list in any way nor should it make a copy of the list and alter that. The following shows several sample runs of the completed function. Please be aware that these are just examples. The function must work correctly on all lists, and you may not make any assumptions about the values found in the list: Python 3.7.0 Shell File Edit Shell Debug Options Window Help >>> val = findMaxLenSet([]) >>val >>val >>> val >>val findMaxLenset(['test', [[[[[{1, 2}], {3, 4, 5}]]]], 'cat', {6, 7, 8, 'nine ', 10}]) >>val >>val Ln: 93 Col: 4

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

Question

7. Explain why retirees may be valuable as part-time employees.

Answered: 1 week ago

Question

3. Provide advice on how to help a plateaued employee.

Answered: 1 week ago