Question: Python Write a function get_max(my_list) The function gets a parity sorted list, my_list, which is also almost balanced, as a parameter. my_list is not empty.




Python Write a function get_max(my_list) The function gets a parity sorted list, my_list, which is also almost balanced, as a parameter. my_list is not empty. The function returns the max value in my_list. Requirement: The function should be efficient in time and space. In addition to the code, write in the answer notebook : 1. What is the time of your code ? Time 01 ____) == 2. What is the Space of your code ? Space == 00 01 __ Let my_list be a list of positive integer numbers. All elements are greater than 0. We say that my_list is parity sorted if all elements that are even are sorted left to right, small to big. Also all elements that are odd are sorted left to right, small to big. We say that a parity sorted list is almost balanced if the list can not have more than 2 successive elements (one after the other) with the same parity (either all even or all odd). Example: 12 39 14 14 11 21 16 31 22 31 49 32 62 51 Even elements (left to right) are 12, 14, 14, 16, 22, 32 , 62 Odd elements (left to right) are 3,9,11, 21, 31, 31, 49, 51 We can see : all even elements are sorted left to right, small to big. Also all odd numbers are such. In addition no more than 2 successive elements (one after the other) of the same parity. If a list does not have even elements then we can think as all even elements are sorted. Also the same for the odd elements. Specifically, an empty list or 1 element list is parity sorted, and also almost balanced
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
