Question: CSc 120: Diagonal to List (Recursive) Expected Behavior Write a recursive function diag2list rec(grid), where grid is an nx n square list of lists, that

 CSc 120: Diagonal to List (Recursive) Expected Behavior Write a recursive

CSc 120: Diagonal to List (Recursive) Expected Behavior Write a recursive function diag2list rec(grid), where grid is an nx n square list of lists, that returns a list consisting of the diagonal elements of grid, i.e., the elements grid Ol[O], gridl1111)],... gridn1n1 You can assume that grid is a square list of lists, i.e., you don't have to check for this. You may find a helper function useful for this problem Programming Requirements Solve this problem using recursion. You are allowed to use only the following programming constructs: if statements . return statements; - assignment; recursive function calls (if you use any helper functions then these must all be recursive as well) comparison operations (- list indexing and slicing: list concatenation/extension. Solutions that go outside these constructs, e.g., by using for/while loops or list comprehensions, will not get credit. Examples 1. diag2list_rec(ll1,2,3],14,5,61,17,8,911) 2. diag2list_rec (1,213,41) 3. diag21ist rec(1]1) 4. diag21ist_rec () return value: [1,5,9 return value: 1,4 return value: 1] return value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!