![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 24.03.2021 21:30, tiffcarina69
Lists can hold integers, strings, and even other lists, for example [ ["test"], [ ], [1. ["me"] ] ) is a list with three elements: a list ["test"), an empty list [ ], and a list [1. ["me"] ].
When objects like lists or dictionaries contain objects of the same type as themselves, we say the inner objects are nested in the outer objects For an object in a nested list, we will call the number of enclosing outer lists the depth of that object.
For example, in the list [ ["test"], [ ], [1, ["me"] } ], the list ["test") is at a depth of 1, the string "test" is at a depth of 2 and the string "me" is at a depth of 3.
Write a recursive function to calculate the maximum depth of any object in a given list.
Name the function maximum_nesting_depth(x), where x is a list, and return an integer representing the maximum depth of any object inx.
You can assume the test cases will not be the empty list.
Examples:
maximum_nesting_depth([ ("test"], [], [1, ["me"] ] ]) = 3
maximum_nesting_depth(["test"]) = 1
maximum_nesting_depth([ 1, ["me"] ] = 2
Note that empty lists will not contribute to the nesting depth; we are computing the maximum nesting depth of any object maximum_nesting_depth [ "test", [ ] ] is 1 because "test" is at depth 1 maximum_nesting_depth([ "test", [[ ]]]is 2 because[ ] is at depth 2 and empty Hint 1: You can use the following recursive definition: Base Case: If x is a list containing no lists, the maximum nesting depth is 1. Recursive Case: If x is a list containing a list with maximum nesting depth of n, then x has a maximum nesting depth of at least n+1. Hint 2: For an object e, the expression "isinstanceſe, list)" will be True if and only if e is a list.
![answer](/tpl/images/cats/otvet.png)
Answers: 2
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 01:00, arturocarmena10
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
Do you know the correct answer?
Lists can hold integers, strings, and even other lists, for example [ ["test"], [ ], [1. ["me"] ] )...
Questions in other subjects:
![Konu](/tpl/images/cats/mat.png)
Mathematics, 08.07.2021 23:40
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 08.07.2021 23:40
![Konu](/tpl/images/cats/mat.png)
Mathematics, 08.07.2021 23:40
![Konu](/tpl/images/cats/fizika.png)
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 08.07.2021 23:50