01:198:111 Lecture Notes - Lecture 6: Call Stack, Global Variable

46 views2 pages
Verified Note

Document Summary

When something is specified in terms of itself. Divide and conquer type of approach in coding. Tree recursively= node consisting of left subtree and right subtree. # of nodes= 1+ (left subtree nodes) + (right subtree nodes) Fac (4)= 4fac(3) 3fac(2) 2fac(1) 1fac(0) Fib of (n) = fib(n-1) + fib(n-2) Need two cases from the start to compute. Sum of sequence of fibonacci squares is next number*current number. Wrapped in a class before the main function. Functions can also be put in libraries (own main in another class) There can only be 1 main function. Run-time stack= locations where data (variables) can be stored. Needs to be a return address after function is called. Function stack destroyed with return code public static int factorial(int n) { Move 1 from column column a to column c. Move 1 from column a to column b. Move 2 from column a to column c. Move 1 from column b to column c.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents