jagomart
digital resources
picture1_Programming Pdf 186025 | Cse230 L04 Recursion


 130x       Filetype PDF       File size 0.42 MB       Source: www3.cs.stonybrook.edu


File: Programming Pdf 186025 | Cse230 L04 Recursion
cse 230 intermediate programming in c and c recursion fall 2017 stony brook university instructor shebuti rayana what is recursion sometimes the best way to solve a problem is by ...

icon picture PDF Filetype PDF | Posted on 01 Feb 2023 | 2 years ago
Partial capture of text on file.
           CSE 230
    Intermediate Programming 
          in C and C++
           Recursion
            Fall 2017
         Stony Brook University
        Instructor: Shebuti Rayana
                  What is recursion?
                  ■ Sometimes, the best way to solve a 
                        problem is by solving a smaller version 
                        of the exact same problem first
                  ■ Recursion is a technique that solves a 
                        problem by solving a smaller problem 
                        of the same type
                                   Shebuti Rayana (CS, Stony Brook University)                                                        2
         Recursive Function
         ■ A function is called recursive if it calls itself
         ■ In C, all functions can be used recursively
         ■ Example:
         – This will act like an infinite loop  
                  Shebuti Rayana (CS, Stony Brook University)     3
         Recursive Function: Example
         ■ This code 
            computes the sum 
            of first n positive 
            integers.
         ■ For n = 4
             Function Call             Value returned
            sum(1)         1
            sum(2)         2+sum(1) or 2+1
            sum(3)         3+sum(2) or 3+2+1
            Sum(4)         4+sum(3) or 4+3+2+1
                 Shebuti Rayana (CS, Stony Brook University)     4
The words contained in this file might help you see if this file matches what you are looking for:

...Cse intermediate programming in c and recursion fall stony brook university instructor shebuti rayana what is sometimes the best way to solve a problem by solving smaller version of exact same first technique that solves type cs recursive function called if it calls itself all functions can be used recursively example this will act like an infinite loop code computes sum n positive integers for call value returned or...

no reviews yet
Please Login to review.