I’m supposed to find the smallest value in a list of nodes using the “extreme pattern for nodes.” I am not allowed to use the min() function. I think I need to use a loop or recursion of some sort. Here is the “extreme pattern” for arrays:
largest = items[0]
for i in range(0,len(items),1):
if (items[i] > largest):
largest = items[i]
But this pattern will not work on lists like this one which contains nodes:
[1, [23, [53, [54, [5, None]]]]]
How do I implement a similar pattern to find the smallest value in a list like the one above?
1 Answer