Class Notes (1,200,000)
US (500,000)
Cornell (1,000)
CS (100)
CS 2110 (30)
Gries (30)
Lecture 8

CS 2110 Lecture Notes - Lecture 8: Palindrome, Exponentiation, Circular Definition


Department
Computer Science
Course Code
CS 2110
Professor
Gries
Lecture
8

This preview shows page 1. to view the full 4 pages of the document.
Lecture 8 - Recursion
Circular definition: a definition that is circular!!
Recursion in real life:
<noun phrase> = <noun>, or <adj><noun phrase> or <adverb><noun>
Factorial function
Family trees - great great great great… great gradother
Two different questions
How does it execute?
How do we understand recursive methods?
Stack: List with at least two basic ops:
Push an element onto its top
Pop remove an element
Stack Frame
Method call: push a frame for call on stack. Assign argument values to
parameters. Execute method body. Use the frame for the call to
reference local variables and parameters.
End of method call: pop its frame from the stack; if it is a function leave
the return value on top of stack.
To execute a method Call:
Push a frame for the call on the stack
Assign argument values to parameters
Execute method body
Pop frame for call from stack, and push returned value on stack
Stack frame of sumDig(824):
How does it execute?
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version