Bifalgorithm post · Computer science one · Recursion

What happens when a function calls itself?

What happens when a function calls itself? (Computer science one · Recursion) — "The function in this case is called CountDown (). In Line 5 the function calls…

Ideas in this flowchart

  • Recursion occurs when a function calls itself
  • The function in this case is called CountDown()
  • In Line 5, CountDown() calls itself with a decremented value
  • A function that calls itself is called a recursive function
  • A language supports recursion when it allows functions to call themselves
  • Functions commonly invoke other functions
  • Each function call creates a new stack frame on the program stack
  • A function calling itself is not fundamentally different from calling another function
Feed/

What happens when a function calls itself?

No cover

Channel

Computer science one

1 page

"The function in this case is called CountDown (). In Line 5 the function calls itself on a decremented value. When a function calls itself, it is a recursive function. When a language allows functions to call themselves they support recursion . This is not that odd of a concept. We’ve seen many examples where functions invoke (call) other functions. Each function call simply creates a new stack frame on the program stack. There is nothing particularly special about which functions call which other functions, so there is little difference when a function calls itself."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.