1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
3241004551 [841]
3 years ago
5

Find the max and min of a set of values using recursion Find the max and min of a set of values using recursion. First input the

values. The first value inputted is the number of additional data items to input. For instance, if the input is: 3 1 2 3
Computers and Technology
1 answer:
matrenka [14]3 years ago
4 0

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)) )

You might be interested in
A type of printer is used to price model and shape is called
balandron [24]

Either a 3d,2d printer, or a price label gun

7 0
4 years ago
A) Write a program that asks the user for the amount of money they will take on holiday and convert this into the equivalent amo
Lelu [443]

def func():

   money = int(input("How much money will you have on holiday? "))

   print("You will have {} euros.".format(int(money * 1.11)))

   money = int(money * 1.11)

   fifty = 0

   twenty = 0

   ten = 0

   five = 0

   while True:

       if money - 50 >= 0:

           fifty += 1

           money -= 50

       elif money - 20 >= 0:

           twenty += 1

           money -= 20

       elif money - 10 >= 0:

           ten += 1

           money -= 10

       elif money - 5 >= 0:

           five += 1

           money -= 5

       if money < 5:

           print("You will have {} fifties, {} twenties, {} tens, {} fives, and {} ones".format(fifty, twenty, ten, five, money))

           return

func()

I hope this helps!

5 0
3 years ago
Which arcade game was co-created by steve jobs and steve wozniak?
Charra [1.4K]

Answer:

Breakout

Explanation:

5 0
3 years ago
Which type of software is primarily used to organize a collection of information for easy access?
lukranit [14]

Answer:

option B database management software

mark as brainliest answer

8 0
4 years ago
• Bài 5: Cho cạnh a, b và c như hình sau. Tính diện tích hình được tô màu. Biết b là đường kính của nữa hình tròn. Xác định bài
umka21 [38]

Answer:

huh?

Explanation:

what I don't understand

5 0
3 years ago
Other questions:
  • Assume that the main method of the class named Welcome does not contain any compile-time errors. What is the name of the file ge
    11·1 answer
  • Two positive outcomes generally associated with modern computing are greater _____.
    12·2 answers
  • Look at the trend in the US labor force participation rate. If increasing the number of women and men in the labor force can be
    13·1 answer
  • Which Boolean operator produces the result 1 only if both values are 1? Which Boolean operator produces the result 0 only if bot
    13·1 answer
  • If the executives for Office Max LLC, a chain of office supply stores, developed the chain's objectives by asking buyers and sto
    11·1 answer
  • Decimal numbers is equivalent to binary 110
    5·1 answer
  • If an electric circuit has 30ohms and 10amps. How many volts the battery voltmeter should read?
    10·1 answer
  • Which of the following events happened first
    15·2 answers
  • PLEASE HELP WILL GIVE BRAINLIEST!!!’
    15·1 answer
  • Why big data influnce the rise of AI<br><br>​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!