Question: printe 5 array_to_list recursive (data) Include this function in the file linked_list_recursion_part_2.py Repeat the problem from the previous project - but this time, you must

 printe 5 array_to_list recursive (data) Include this function in the file
linked_list_recursion_part_2.py Repeat the problem from the previous project - but this time,

printe 5 array_to_list recursive (data) Include this function in the file linked_list_recursion_part_2.py Repeat the problem from the previous project - but this time, you must do it recursively. Remember to handle the corner cases! This function must be recursive, but is not required to obey the Annoying Requirements 5.1 Hints If you ever find yourself thinking, "How do I put a node on the tail of the list? you're probably going about this backwards. To recursively build a list, we will usually it possible) build a smaller list, and then add one more element at the head. How would you recurse into the array, in order for that to be possible? 6 accordion recursive (head) Include this function in the file linked_list_recursion_part_2.py accordion_recursive (head) takes a linked list (which might be empty) as its only parameter and returns a new linked ligt, where every other node has been removed. The new list must use the same nodes as the original list don't create any new ones). When removing nodes from the list, you must remove the old head, the node 2 After the old head, and the node 2 after that, out to the end of the list. For instance, if the input list is like this: 10 -> 20> -1 -> Masdf" => 13 -> "qwerty" -> 1024 then the list that you return must look like this: 20 -> "asdf" -> "qwerty" If the old list contained only a single node, or was empty, retium an empty This function must be recursive, but is not required to obey the Annoying Requirement 3 6.1 Hints You may be tempted to recurse into head.next at every step. But this is not going to work - because then, sometimes your code will want to keep the head. and other times, your code will want to discard it. Since we don't allow helpers, how are you going to do this? Remember: while your function has to be recursive, it doesn't have to always recurse to the very next node. Where should you recurse, really, if you want to make accordion work? 7 pair recursive (head, head2) This function takes two lists, which may be of different lengths (either or both of them might be empty). It builds new ListNode objects, where the value of each one is a tuple, consisting of one value from the first list, and one value from the second list, in the same order as they existed in those input lists If the lists are different lengths, then the length of the returned list will be equal to the length of the shorter one, This function must be recursive, but is not required to obey the Annoying Requirements. I 7.1 EXAMPLE Suppose that the input lists are as follows: headi: 123 456 789 had2: abc" -> "def" => "ghi" => "jk1" then the list that you return must look like this: (123,"abc") 45 (456, "def") -> (789,"ghi") 7.2 Recursing on Two Things So far, all of the recursive functions you've done have been over a single thing either an integer, or a linked list. But there are some problems like this one. where you recurse over two things in parallel. While this seems weird at first, if you look at it carefully, you'll realize it's not a lot more complex than what you've already done in this problem you will pair the first value from list with the first value from list 2. and then the recond value from list 1 with the second value from list 2. th so on. So really the only trick here is that when you recure, you must recure into the next fied of both list at the same time, printe 5 array_to_list recursive (data) Include this function in the file linked_list_recursion_part_2.py Repeat the problem from the previous project - but this time, you must do it recursively. Remember to handle the corner cases! This function must be recursive, but is not required to obey the Annoying Requirements 5.1 Hints If you ever find yourself thinking, "How do I put a node on the tail of the list? you're probably going about this backwards. To recursively build a list, we will usually it possible) build a smaller list, and then add one more element at the head. How would you recurse into the array, in order for that to be possible? 6 accordion recursive (head) Include this function in the file linked_list_recursion_part_2.py accordion_recursive (head) takes a linked list (which might be empty) as its only parameter and returns a new linked ligt, where every other node has been removed. The new list must use the same nodes as the original list don't create any new ones). When removing nodes from the list, you must remove the old head, the node 2 After the old head, and the node 2 after that, out to the end of the list. For instance, if the input list is like this: 10 -> 20> -1 -> Masdf" => 13 -> "qwerty" -> 1024 then the list that you return must look like this: 20 -> "asdf" -> "qwerty" If the old list contained only a single node, or was empty, retium an empty This function must be recursive, but is not required to obey the Annoying Requirement 3 6.1 Hints You may be tempted to recurse into head.next at every step. But this is not going to work - because then, sometimes your code will want to keep the head. and other times, your code will want to discard it. Since we don't allow helpers, how are you going to do this? Remember: while your function has to be recursive, it doesn't have to always recurse to the very next node. Where should you recurse, really, if you want to make accordion work? 7 pair recursive (head, head2) This function takes two lists, which may be of different lengths (either or both of them might be empty). It builds new ListNode objects, where the value of each one is a tuple, consisting of one value from the first list, and one value from the second list, in the same order as they existed in those input lists If the lists are different lengths, then the length of the returned list will be equal to the length of the shorter one, This function must be recursive, but is not required to obey the Annoying Requirements. I 7.1 EXAMPLE Suppose that the input lists are as follows: headi: 123 456 789 had2: abc" -> "def" => "ghi" => "jk1" then the list that you return must look like this: (123,"abc") 45 (456, "def") -> (789,"ghi") 7.2 Recursing on Two Things So far, all of the recursive functions you've done have been over a single thing either an integer, or a linked list. But there are some problems like this one. where you recurse over two things in parallel. While this seems weird at first, if you look at it carefully, you'll realize it's not a lot more complex than what you've already done in this problem you will pair the first value from list with the first value from list 2. and then the recond value from list 1 with the second value from list 2. th so on. So really the only trick here is that when you recure, you must recure into the next fied of both list at the same time

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!