Computer Science
Recursive Algorithm
A recursive algorithm is a problem-solving approach where a function calls itself to solve smaller instances of the same problem. This technique is commonly used in computer science to solve problems that can be broken down into smaller, similar sub-problems. Recursive algorithms often involve a base case to stop the recursion and prevent infinite loops.
Written by Perlego with AI-assistance
Related key terms
1 of 5
5 Key excerpts on "Recursive Algorithm"
- No longer available |Learn more
- (Author)
- 2014(Publication Date)
- Learning Press(Publisher)
________________________ WORLD TECHNOLOGIES ________________________ Chapter 4 Recursion & Parallel Algorithm Recursion (computer science) Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem. The approach can be applied to many types of problems, and is one of the central ideas of computer science. The power of recursion evidently lies in the possibility of defining an infinite set of objects by a finite statement. In the same manner, an infinite number of computations can be described by a finite recursive program, even if this program contains no explicit repetitions. Most high-level computer programming languages support recursion by allowing a function to call itself within the program text. Some functional programming languages do not define any looping constructs but rely solely on recursion to repeatedly call code. Computability theory has proven that these recursive-only languages are mathematically equivalent to the imperative languages, meaning they can solve the same kinds of problems even without the typical control structures like “while” and “for”. Tree created using the Logo programming language and relying heavily on recursion. ________________________ WORLD TECHNOLOGIES ________________________ Recursive data types Many computer programs must process or generate an arbitrarily large quantity of data. Recursion is one technique for representing data whose exact size the programmer does not know: the programmer can specify this data with a self-referential definition. There are two flavors of self-referential definitions: inductive and coinductive definitions. Inductively-defined data An inductively-defined recursive data definition is one that specifies how to construct instances of the data. - eBook - PDF
- L.E. Sanchis(Author)
- 1992(Publication Date)
- North Holland(Publisher)
We discuss the manner in which calling algorithms are written and executed in the well-known language of locations involving locations X O , X I , . . ., and each location contains numerical values that change during the computation. The execution of a Recursive Algorithmobviously depends on the manner in which the instructions are executed. While the explicit instructions are independent of the algorithm in which they appear, in the sense that they can be executed without reference to any algorithm in the system, a call instruction involves one or more algorithms. This is basically a recursive relation that we must take as a primitive. We describe the execution of recursive F-algorithms in a system A in terms of two ideal entities: one that we call the computing A-machine, and another that we call the 3-oracle. 112 L.E. Sanchis The computing machine is a recursive machine and it has two different but related types of actions. First, the machine executes instructions during a compu- tation involving a particular algorithm. In general, these instructions are explicit or calls involving algorithms in the system. Second, the computing machine computes algorithms with a given input and returns a value whenever the computation is defined. The machine is recursive in the sense that the execution of algorithms requires the execution of instructions, and the execution of instructions requires the execu- tion of algorithms. We propose this as a primitive computational concept in order to formulate the extended Church’s thesis. On the other hand, if we work in the context of a given formalization, given by a formal machine or formal programming language, the recursive computation described above can be formalized, usually via some definition by induction. This is a well known phenomenon where, for exam- ple, the computation of a Turing machine can be formalized, although the notion of machine computation in general cannot be formalized. - eBook - PDF
C++ Programming
From Problem Analysis to Program Design
- D. Malik(Author)
- 2017(Publication Date)
- Cengage Learning EMEA(Publisher)
Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. Problem Solving Using Recursion | 1039 1 5 execute an infinite recursive function on a computer, the function executes until the system runs out of memory and results in an abnormal termination of the program. Recursive functions (algorithms) must be carefully designed and analyzed. You must make sure that every recursive call eventually reduces to a base case. This chapter pro- vides several examples that illustrate how to design and implement Recursive Algorithms. To design a recursive function, you must do the following: a. Understand the problem requirements. b. Determine the limiting conditions. For example, for a list, the limiting condition is the number of elements in the list. c. Identify the base cases and provide a direct solution to each base case. d. Identify the general cases and provide a solution to each general case in terms of smaller versions of itself. Problem Solving Using Recursion Examples 15-1 through 15-3 illustrate how Recursive Algorithms are developed and implemented in C++ using recursive functions. EXAMPLE 15-1 LARGEST ELEMENT IN AN ARRAY In Chapter 8, we used a loop to find the largest element in an array. In this example, we use a Recursive Algorithm to find the largest element in an array. Consider the list given in Figure 15-2. The largest element in the list in Figure 15-2 is 10. Suppose list is the name of the array containing the list elements. Also, suppose that list[a]...list[b] stands for the array elements list[a], list[a + 1], ..., and list[b]. For example, list[0]...list[5] represents the array elements list[0], list[1], list[2], list[3], list[4], and list[5]. - eBook - PDF
- Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser(Authors)
- 2013(Publication Date)
- Wiley(Publisher)
There are many examples of recursion in art and nature. For example, fractal patterns are naturally recursive. A physical example of recursion used in art is in the Russian Matryoshka dolls. Each doll is either made of solid wood, or is hollow and contains another Matryoshka doll inside it. In computing, recursion provides an elegant and powerful alternative for per- forming repetitive tasks. In fact, a few programming languages (e.g., Scheme, Smalltalk) do not explicitly support looping constructs and instead rely directly on recursion to express repetition. Most modern programming languages support functional recursion using the identical mechanism that is used to support tradi- tional forms of function calls. When one invocation of the function make a recur- sive call, that invocation is suspended until the recursive call completes. Recursion is an important technique in the study of data structures and algo- rithms. We will use it prominently in several later chapters of this book (most notably, Chapters 8 and 12). In this chapter, we begin with the following four il- lustrative examples of the use of recursion, providing a Python implementation for each. • The factorial function (commonly denoted as n!) is a classic mathematical function that has a natural recursive definition. • An English ruler has a recursive pattern that is a simple example of a fractal structure. • Binary search is among the most important computer algorithms. It allows us to efficiently locate a desired value in a data set with upwards of billions of entries. • The file system for a computer has a recursive structure in which directories can be nested arbitrarily deeply within other directories. Recursive algo- rithms are widely used to explore and manage these file systems. We then describe how to perform a formal analysis of the running time of a Recursive Algorithm and we discuss some potential pitfalls when defining recur- sions. - eBook - PDF
Computer Algebra and Symbolic Computation
Elementary Algorithms
- Joel S. Cohen(Author)
- 2002(Publication Date)
- A K Peters/CRC Press(Publisher)
5 Recursive Algorithms In this chapter we examine how recursion is used to implement algorithms in computer algebra. We begin, in Section 5.1, by describing how a sim ple recursive procedure is implemented by a CAS. In Section 5.2, we give recursive procedures for a number of operators and describe an approach using transformation rules that provides a simple way to implement some recursive operations. Finally, in Section 5.3 we describe a recursive algo rithm for a simple version of the Integral operator that utilizes some basic integration rules together with the substitution method. 5.1 A Computational View of Recursion In Chapter 3 we gave the following recursive definition for the factorial operation: For n — 4, the computation based on this definition (5.1) proceeds as follows: To perform the calculation, we repeatedly apply (5.1) until n = 0 is en countered. Once this point is reached, 0 ! is replaced by the value 1 , and the numerical computation proceeds as indicated by the parentheses in the second line of Equations (5.2). 171 172 5. Recursive Algorithms Figure 5.1. An MPL recursive procedure for n. (Implementation: Maple (txt), Mathematica (txt), MuPAD (txt).) Figure 5.1 shows an MPL recursive procedure that performs this calcu lation. For the case n > 0, the procedure calls on itself (line 4) to perform a “simpler” version of the calculation. A procedure that calls on itself di rectly (as in this example) or indirectly through a sequence of procedures is called a recursive procedure. The case n = 0 (lines 1, 2 ) is called a ter mination condition for the procedure, since it is defined directly and does not require further calls on Rec-fact. For each positive integer n, the cal culation is eventually reduced to the termination condition which stops the recursion. Each recursive procedure must have one or more termination conditions. Let’s trace the execution of the procedure in response to the evaluation of Rec-fact(4 ) from the interactive mode.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.




