TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Flowgorithm

    Flowgorithm Infinite Recursion Example

    Overview

    In this tutorial, we will understand Infinite Recursion, the common mistake that programmers make while designing recursive functions in Flowgorithm flowcharts.

    A recursive function is a function that invokes itself. Let’s understand it with a simple example.

    A simple example of infinite recursion occurs when the Main flowchart invokes itself. In this example, the flowchart will fall in infinite recursion and the control never reaches the End symbol.

     

    Main Invoke Itself Recursion

    Stack Overflow

    This error indicates that the Maximum Stack Size has been exceeded by the program.  If the flowchart program exceeds this size in the case of an infinite recursive call, the following runtime error would be displayed: Stack Overflow

    The Flowgorithm tool uses a Stack to store function activation records.  An activation record is a chunk of memory that stores the function parameters, local variables, and the function return value.

    Example

    Let’s take another example from the earlier post. The recursive function is RSum.

    The recursive function example is from the post: Recursion In Flowgorithm Flowchart

     

     

    Flowgorithm Infinite Recusion Stack Overflow Error

    Call Stack

    To view the Call Stack, launch the Variable Watch Window and click on the ‘Show the Stack’ button. We can notice that the recursion doesn’t have a base case.

    A base case is a halting case that stops the recursion. In the base case, the function returns and doesn’t call itself. In this case, the recursion doesn’t stop and results in an infinite recursion.

     

    Call Stack Infinite Recursion

     

    To fix the flowchart we need to debug and stop the recursion using the base case. In this case, when N == 1 we can make the function return sum = 1 instead of calling recursively itself which is a defect.

    —

    Flowgorithm Tutorials

    Flowgorithm flowchart tutorials on this website:

    https://www.testingdocs.com/flowgorithm-flowchart-tutorial/

    Flowgorithm Website

    For more information on the Flowgorithm tool, please visit the official website at:

    http://flowgorithm.org/

    Related Posts

    Print Triangle Pattern Flowchart

    Flowgorithm /

    Print Triangle Pattern Flowchart

    Flowgorithm Breakpoint Symbol

    Flowgorithm /

    Flowgorithm Conditional Breakpoint Statement

    File Read Declare Variables

    Flowgorithm /

    Flowgorithm Read Numbers from File Example

    File Search Input File Flowgorithm

    Flowgorithm /

    Search Text File Flowchart Example

    Flowgorithm Turtle Graphics Symbols

    Flowgorithm /

    Flowgorithm Turtle Graphics Symbols

    ‹ Benefits of Flowgorithm Software› Flowgorithm Flowchart to Convert Feet to Meters

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com