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
Is it better to meet online or offline<br> (Please answer QUICK)<br><br> Thanks :')
topjm [15]

Answer:

online, its faster

Explanation:

7 0
3 years ago
Read 2 more answers
How does the Evaluate Formula dialog box help fix errors?
butalik [34]
C Bc I just did it and got it right
6 0
3 years ago
Read 2 more answers
Both the USB flash drive and the DVD are data storage devices, but they both have numerous differences. Both can contain insane
o-na [289]
It Is Wonderful Add That A "USB" Can Hold Anything At All But Some Thing's "System's" Need A Specific Format Like The "PlayStation Three" With "FAT32" Format.
6 0
3 years ago
Which Excel function or tool will you use to display the cells that are referred to by a formula in the selected cell
Alenkasestr [34]

Answer:

Trace Precedent

Explanation:

Trace Precedent is a Microsoft Excel tool that is mostly used in auditing work to evaluate the connection or linkage between the cells in a spreadsheet. It is used to display the cells that are referred to by a formula in the selected cell. This is to locate the basis of an error in knowing how the formulas are adapted.

This can be done by clicking on the Formulas tab, then click on Formulas Auditing, then click on Trace Precedents.

Hence, in this case, the correct answer is TRACE PRECEDENTS.

7 0
3 years ago
When writing research questions, use action words, such as
irina1246 [14]

Answer: Effect

Explanation:

Research questions are demonstrated as the questions that directs or specifies the dimension of the research for a particular work and helps to determine the objectives of the paper or essay.

As per the question, while writing or farming research questions, action verb like 'effect' must be used as it would help determine the impact of a particular research question on the content and efficacy of the research and thus, frame questions that propose a clear, concise, intricate, and debatable thesis statement and offer an effective dimension to the essay that creates a valid impact on the audience.

6 0
3 years ago
Read 2 more answers
Other questions:
  • 11. You should type _
    6·2 answers
  • The most effective way to perform data entry is to keep your hands on the keyboard and press to move to the text cell in the row
    10·1 answer
  • All of the following are recommended to secure a wireless network EXCEPT:
    5·2 answers
  • _____ _____ deals with the definitions properties of mathematical models of computation.
    8·1 answer
  • ​User documentation _____. Group of answer choices ​allows users to prepare overall documentation, such as process descriptions
    9·1 answer
  • A customer has a computer for a home business, but wants to have another computer as a web server. What would be the best soluti
    11·2 answers
  • Which of these is not a valid form<br>layout in Microsoft Access?​
    11·1 answer
  • In 1981, the first digital icons were launched for users in _________, which was the first computer with a GUI operating system.
    12·1 answer
  • You decide to test an audio clip that you have inserted into your presentation, but before you do that you make sure that the co
    6·1 answer
  • Write an algorithm to verify a number as even​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!