Question

In: Computer Science

Describe the similarities between using recursion versus iteration. Describe the difference between using recursion versus iteration.

  1. Describe the similarities between using recursion versus iteration.
  2. Describe the difference between using recursion versus iteration.

Solutions

Expert Solution

1 ans:

Similarities

1)The one of the main similarity is both the recursion as well as iteration are involved repetition

2)The recursion and iteration both can only use control structure which means recursion used if and else if and else statements based on the recursion call the method n number of times which is repetition method and iteration uses for loop or while loop which both are control structures so it was another similarity

2 ans:

Differences:

1)Iteration may or may not be function call based on the usage while use for loop or while loop with the loop if we need call a function than we can call otherwise we can't call it was called based on usage but coming to recursion the function call must be done repeatedly so then we can achieve recursion it was the difference

2)in iteration set of instructions can each time executed repeatedly but in recursion it can done based on conditional statements

#if you have any doubt or more information needed comment below..i will respond as possible as soon..thanks,..


Related Solutions

Please explain the difference between using the pKa value of anamino acid versus using the...
Please explain the difference between using the pKa value of an amino acid versus using the pI of an amino acid to determine the change and whether it will be protonated or deprotonated at a particular pH. For example, we say that histidine has a pKa of 6, but the isoelectronic point is 7.59.   If we have a solution with a pH of 7, what would histidine's charge be? If I want to quickly determine or automatically know the charge...
Explain the similarities and differences of counter-controlled iteration and sentinel-controlled iteration. Also, give an example of...
Explain the similarities and differences of counter-controlled iteration and sentinel-controlled iteration. Also, give an example of how each would be used in a computer program.
What is the difference between reporting an estimate of mu using a margin of error versus...
What is the difference between reporting an estimate of mu using a margin of error versus using a confidence interval?
Recursion and Iteration in C++ Locate the TODO comments in the hw02.h file. These comments provide...
Recursion and Iteration in C++ Locate the TODO comments in the hw02.h file. These comments provide direction on what needs to be done. // hw02.h #ifndef CSC232_HW02_H #define CSC232_HW02_H // TODO: All pre-conditions must be validated using the assert function imported from the following library. // TODO: You are not allowed to use the pow function in this assignment! #include <cassert> #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE !FALSE #endif #define USE_MAIN_INPUT_FILE FALSE #define USE_DEMO_INPUT_FILE FALSE #define...
This function uses a curious mix of iteration and recursion: function F(n) if n < 1...
This function uses a curious mix of iteration and recursion: function F(n) if n < 1 return 1 t <- 0 for i <- 0 to n for j <- i to n t <- t + j return t + F(n-1) What is the number of basic operations (additions and subtractions) performed? Answer: Θ(n³) Could you tell me how I can solve this problem??
In eukaryotes: what is the difference between the regulation of general versus specific translation? Describe one...
In eukaryotes: what is the difference between the regulation of general versus specific translation? Describe one regulatory mechanism per each type.
Describe the crash of 1929 versus the financial crisis of 2008. What are the similarities and...
Describe the crash of 1929 versus the financial crisis of 2008. What are the similarities and what are the differences
What is the difference and similarities between SVM and Logistic Regression?
What is the difference and similarities between SVM and Logistic Regression?
Outline the difference and similarities between manufacturers and service providers
Outline the difference and similarities between manufacturers and service providers
Rewrite your program for finding Pascal's Triangle to use iteration (loops) instead of recursion. Include in...
Rewrite your program for finding Pascal's Triangle to use iteration (loops) instead of recursion. Include in both algorithms code to keep track of the total time used to run the algorithms in milliseconds. Run these algorithms for n = 10, n = 20, and n = 30. Print out both the original output and the time to run for both algorithms. Please make sure you comment your code thoroughly. The code should be nicely formatted and should use proper variables.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT