Question

In: Computer Science

One of your chapters this week is on recursion. Below are the three recursive algorithms laws:...

One of your chapters this week is on recursion. Below are the three recursive algorithms laws:

1. A recursive algorithm must have a base case.

2. A recursive algorithm must change its state and move toward the base case.

3. A recursive algorithm must call itself, recursively.

Do you have any examples of recursive algorithms used in the real-world?

Approximately 175 words in the answer.

Solutions

Expert Solution

Recursion is a programming technique in which we use function or procedures or algorithm which calls itself in a step which has a termination condition or base case so that successive repetitions are processed up to the critical step where the conditions are met. The main advantages of using recursion are it reduces the time complexity and lesser lines of code when compared to the iterative method. There are many real-world cases where the recursive algorithm is used.

For example, consider you in any application you open a folder which may or may not contain files and we use recursion here in following way. Here first we call the recursion function with folder name to open. Then the recursive function base case checks the condition that folder is empty or not. If it is empty it breaks the recursive function chain is terminated and stop. If the base condition is not met then we read the file popped out the file from folder shows it to the user and call the recursive function again. This process continues and the user gets all the files present in the folder. Once all files are read the base case will halt the recursion program. we can see this example in every application in which we read anything from folder memory. Such as getting the songs name in a folder in windows application or phone application.

I hope you got the answer and understand it.

Thank you:):)


Related Solutions

THIS IS ALL ON PYTHON Recursion Practice Recall from lecture that a recursive function is one...
THIS IS ALL ON PYTHON Recursion Practice Recall from lecture that a recursive function is one that calls on itself. Recursive functions have two parts, the base case which stops the recursion and the recursive step where the function calls upon itself. When designing recursive algorithms, your goal for each step should be to work towards the base case. More abstractly, each recursive call decreases the size of the problem, working ever closer to some trivial case with a defined...
1. Implement the recursive factorial function given below (from the lecture notes on recursion). Develop a...
1. Implement the recursive factorial function given below (from the lecture notes on recursion). Develop a main program that allows the user to enter any integer (positive) integer value, and displays the factorial of that value. The program should allow the user to either keep entering another value, or quit the program. public static int factorial(int n) { if (n == 0 || n == 1) return (1); else return (n * factorial(n-1)); } 2. Determine the largest value for...
Based on the assigned chapters this week, identify three (3) key changes that have advanced HR...
Based on the assigned chapters this week, identify three (3) key changes that have advanced HR and provide a justification to support your selection. From this week’s assigned reading, choose one (1) historical government HR regulation enacted and elaborate on how this new mandate affected all stakeholders involved. Recall stakeholders in any industry, and cover those directly involved and their communities. Provide support for your rationale using the textbook or peer-reviewed outside resources.
Chapters three and four are a review of your training from the first phase of your...
Chapters three and four are a review of your training from the first phase of your principles of microeconomics. The supply and demand framework supposes the application of pure competition and all of its assumptions. Thus its conclusions are the result of these assumptions. discuss the potential managerial problems of analyzing a real world market while only considering the nature of said market to be purely competitive.
Select one of the key concepts from below for your Discussion response for this week. Be...
Select one of the key concepts from below for your Discussion response for this week. Be sure to identify the name of the organization. If organization’s name needs to stay anonymous, please check with the instructor ahead of time regarding how to approach that. Discuss different types of operations management and project management activities that occur at the organization of your choice. Provide examples of single-factor and multifactor productivity measures. Provide two examples of operations management activities at an organization...
This week you will prepare for your class project by using the information in Chapters 4 & 5 on job evaluation and analysis.
Under Project Prep in Weeks 1,2, & 3, you will find information that will help you complete your class Project dueWednesday of Week 4.  This week you will prepare for your class project by using the information in Chapters 4 & 5 on job evaluation and analysis. You will be developing a job description for your position in your chosen organization covering the following points:job titlejob summaryrelationships (report to whom, works with whom & external relationships)qualificationsessential responsibilities
Select one of the following three common computer science problems and describe how recursion can be...
Select one of the following three common computer science problems and describe how recursion can be used to solve this problem more efficiently (sorting, minimum cost spanning tree, knapsack problem). You must generally describe the algorithm that would be used to solve the problem and detail how recursion makes the algorithm more asymptotically efficient.
The overall reactions and rate laws for several reactions are given below. Which one of these...
The overall reactions and rate laws for several reactions are given below. Which one of these represents an elementary step? A) A + 2B → P rate = k[A]2 B) A + 2B → P rate = k[A][B] c) 2A → P rate = k[A] D)A + B + C → P rate = k[A][C] E) A + B → P rate = k[A][B]
Answer one of these three questions below and support your conclusion by selecting and posting a...
Answer one of these three questions below and support your conclusion by selecting and posting a related Ted Talk you find on YouTube. Conflicts can occur in any team environment. While business analysis doesn't appear to include conflict management, it must. Describe your current method(s) for resolving conflict. Is it effective? How so? Ineffective? Why?
For this essay, you will conduct research on one of the laws. You will use your...
For this essay, you will conduct research on one of the laws. You will use your research to write a three- to five-page paper on the law you chose that answers the following questions: When was this law passed and what need or concern did it address? What were the effects of this law (intended and unintended)? Who benefited from this law the most? Were any populations affected by it negatively? What was the public’s reaction to this law? Did...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT