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]
2 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]2 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
Harlequin frogs are an endangered species that live in a small area of Costa Rica. The reasons for the species' decline is unkno
Damm [24]

Answer:

<u>a. The scientists must be careful of how many variables they include in their simulation so they do not cause further harm to the frogs.</u>

Explanation:

It is not statistically accurate to assume that the number of variables included in the simulation would cause further harm to the frogs because we need to <em>remember </em>that a simulation is simply a computerized imitation of a real situation, which is usually not totally alike with a real process.

So in no way from a statistical standpoint, does the scientists' decision on the number of variables causes direct harm to the frogs.

3 0
2 years ago
Explain different types of port?​
lukranit [14]

Answer:

.serial port

.VGA port

.Modem port

explain A port is a channel through which a device communicate with the operating system.

4 0
2 years ago
The accounting number format function is contained within the __________.
bija089 [108]
The accounting number format shows numbers with a dollar sign on one side of the number, embeds a comma each three positions to one side of the decimal point, a presentations numbers to the closest cent. Hope this will help.
8 0
3 years ago
Analyze each of the situations below. Which of the following BEST Illustrates someone who shows appropriate information literacy
maw [93]

The best illustration of information literacy is A. Felix completes an Internet search for a topic for his science class. He takes nearly 30 minutes reading through the different results until he locates a reliable website.

<h3>What is information literacy?</h3>
  • Refers to being able to find and sort through information.
  • Allows for problem solving.

Felix has the problem of looking for information for his topic. He therefore goes online to find, sort through, and then use the information he finds to solve his problem.

In conclusion, the best answer in option A.

Find out more on information literacy at brainly.com/question/25039489.

4 0
2 years ago
Read 2 more answers
You have just searched for the word sun and received the following results: soleil, sonne, and sol. these findings indicate that
Leona [35]
A translator of some sort?
7 0
3 years ago
Other questions:
  • Branching is so called because <br>​
    5·2 answers
  • Two systems are connected by a router. Both systems and the router have transmission rates of 1,000bps. Each link has a propagat
    10·1 answer
  • The slide layout has placeholders for text, charts, and tables. true or false.
    6·2 answers
  • The _________ unit, within the CPU, interprets software instructions and literally tells the other hardware devices what to do,
    5·1 answer
  • What steps are needed for word to create an index
    6·2 answers
  • What keyword must be used on any method (function) on your class that is called from your main() method?
    15·1 answer
  • Your manager asks you to get details on a computer crash. What Windows Administration Tool could you use?
    11·2 answers
  • An employee of a large corporation remotely logs into the company using the appropriate username and password. The employee is a
    10·1 answer
  • Explain different users of computer in briefly?​
    14·1 answer
  • which filename refers to a 16-bit real-mode program that queries the system for device and configuration data, and then passes i
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!