Answer:
This question is answered using Python programming language
def MaxSet(mylist, count):
if (count == 1):
return mylist[0]
return max(mylist[count - 1], MaxSet(mylist, count - 1))
def MinSet(mylist, count):
if (count == 1):
return mylist[0]
return min(mylist[count - 1], MinSet(mylist, count - 1))
count = int(input("Length of set: "))
mylist = []
for i in range(count):
inp= int(input("Input: "))
mylist.append(inp)
print("Minimum: "+str(MinSet(mylist, count)) )
print("Maximum: "+str(MaxSet(mylist, count)) )
Explanation:
This defines the recursion that returns the maximum
def MaxSet(mylist, count):
This following checks for the maximum using recursion
<em> if (count == 1): </em>
<em> return mylist[0] </em>
<em> return max(mylist[count - 1], MaxSet(mylist, count - 1)) </em>
This defines the recursion that returns the minimum
def MinSet(mylist, count):
This following checks for the minimum using recursion
<em> if (count == 1): </em>
<em> return mylist[0] </em>
<em> return min(mylist[count - 1], MinSet(mylist, count - 1)) </em>
The main begins here
This prompts user for length of set
count = int(input("Length of set: "))
This defines an empty list
mylist = []
The following iteration gets user input
<em>for i in range(count):
</em>
<em> inp= int(input("Input: "))
</em>
<em> mylist.append(inp)
</em>
This calls the minimum function
print("Minimum: "+str(MinSet(mylist, count)) )
This calls the maximum function
print("Maximum: "+str(MaxSet(mylist, count)) )