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
alekssr [168]
3 years ago
5

Is recursion ever required to solve a problem? What other approach can you use to solve a problem that is repetitive in nature?

Computers and Technology
1 answer:
Setler79 [48]3 years ago
8 0

Answer:

No you can not tell that recursion is ever required to solve a problem.

Recursion is required when in the problem, the solution of the input depends on the solution of the subsets of the input.

Iteration is also another form of repetitive approach we follow to solve that kind of problems.

But the difference between recursion and iteration is :

  • In recursion we call the function repeatedly to return the result to next level.
  • In iteration certain bunch of instructions in a loop are executed until certain conditions met.

Explanation:

For example in the Fibonacci sequence problem, to find f_{n}, we need to compute f_{n-1} and f_{n-2} before that.

  • In case of recursion we just call the method Fibonacci(n) repeatedly only changing the parameter Fibonacci(n-1), that calculates the value and return it.

                           Fibonacci(n)

                           1. if(n==0 or n==1)

                           2.       return 1.

                           3.else

                           4.      return( Fibonacci(n-1)+Fibonacci(n-1) )

  • But in case of iteration we run a loop for i=2 to n, within which we add the value of current f_{i-1} and f_{i-2} to find the value of f_{i}

                           Fibonacci(n)

                           1. if(n<=2)

                           2.    result = 1

                           3.     else

                           4. result1 =1 and result2=1.

                           5.      {  result = result1 +result2.

                           6.         result1= result2.

                           7.         result2 = result.

                           8.      }

                           9.  output result.

You might be interested in
Any song recommendations, pls dont say 6ix9ine or lil pump
gogolik [260]

I actually do have one tho. Try Megan Tha Stallion.

8 0
3 years ago
Read 2 more answers
Does anyone know a NC wise owl password I can use, it's an emergency!! I can't ask my school because they are closed and I need
snow_tiger [21]
The password would be Apple 123
6 0
3 years ago
_____ consists of computer programs that govern the operation of a computer.
telo118 [61]
Hello <span>Siyujiang8092</span>

Answer: Software<span> consists of computer programs that govern the operation of a computer.

Hope that helps
-Chris</span>
6 0
3 years ago
Write a code in C++ that can save 100 random numbers in an array that are between 500 and 1000. You have to find the average of
Anni [7]

Answer:

#include <iostream>

#include <random>

//here we are passing our array and a int by ref

//to our function called calculateAverage

//void is infront because we are not returning anything back

void calculateAverage(int (&ar)[100], int &average){

 int sum = 0;

 for(int i = 0;i < 100; i++){

   //adding sum

   sum += ar[i];

 }

 //std:: cout << "\naverage \t\t" << average;

//calculating average here

 average += sum/100;

}

int main() {

 int value = 0;

 int average = 0;//need this to calculate the average

 int ar[100];

 //assign random numbers from 500 to 1000

 //to our array thats called ar

 for(int i = 0; i < 100; i++){

   value = rand() % 500 + 500;

   ar[i] = value;

   

 }

 calculateAverage(ar,average);

 // std:: cout << "\naverage should be \t" << average;

 

}

Explanation:

not sure how else this would work without having to pass another variable into the function but I hope this helps!

I commented out the couts because you cant use them according to ur prof but I encourage you to cout to make sure it does indeed calculate the average!

3 0
3 years ago
Destinguish between qualitative data and quantitave
Elden [556K]

For quantitative data, notice the root word 'quantity', which focuses on the amount of something, for example, there are more players on team a than on team b.

For qualitative data, notice the root word quality. Qualitative data focuses on the condition or state of something rather than the amount, for instance, player a does not run as fast as player b.

Hope this helped.

4 0
3 years ago
Other questions:
  • When the minnesota timberwolves encouraged facebook fans to post a great shot of a dunk onto its pinterest page for a chance to
    6·1 answer
  • Which statement about synchronous communication is true?
    15·1 answer
  • If you glare and grit your teeth while telling your friend that you're not frustrated, your nonverbal communication is _________
    6·1 answer
  • You need to set up a network that needs to span multibple buildings. For this reason, you want to use the cabling that supports
    10·1 answer
  • Develop a CPP program to test is an array conforms heap ordered binary tree. This program read data from cin (console) and gives
    9·1 answer
  • How do you validate the type of text that a user enters?
    7·1 answer
  • List the three control problems associated with competingprocesses and briefly define each.
    7·1 answer
  • The interprets the data while it is in RAM​
    8·1 answer
  • Management of software development consist of?
    15·1 answer
  • What is the name given to software that decodes information from a digital file so that a media player can display the file? har
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!