Question: Prob. 2 Without using any built-in functions such as sort, min, max, from Python and its modules, write a function that uses iteration to output

 Prob. 2 Without using any built-in functions such as sort, min,

Prob. 2 Without using any built-in functions such as sort, min, max, from Python and its modules, write a function that uses iteration to output the minimum and maximum values, as well as their positions, of a given list of numeric type. The return data should be a tuple containing two items, each item is a tuple, as ((min, id of min), (max, id of max))). If there is no tie, the position index should be an integer. If there is a tie, the position index should be a list containing all position indexes of the min or max. The interface of your code is listed below, fill in the gap: 1 def sin and max (alist) The input alist is a list of numeric type, find the min and max as well as the positions of min and max of the list, return them as ((min, id.of.min), (max, id.of max)) E.g., calling (a, ida), (b, idb)= min-and-max ([3, 5, 7, 1, 2, 7, 7, 6]) should obtain (a, ida)=(1, 4), (b, idb)-(7, [3, 6, 7]), Note that the position count starts with 1, not 0 3 4 6 8

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!