CS138 Lecture Notes - Lecture 11: Call Stack, Modular Arithmetic, In C

55 views3 pages

Document Summary

Reference parameters are used on midterm i=(i+1)%n: modular arithmetic. With pointers, it"s easy to make subtle & hard-to-find mistakes that you discover much later in program execution (or not at all) Friends you need to get to know: drawing diagrams, a good debugger, assertions & print statements & judicious commenting. Check that logic/assumptions are correct: q. last==null if q. first==null. Check that client is being reasonable: check queue is non-empty before allowing pop. C and java support only call-by-value: i. e. create a copy of calling parameter in the activation record (ar) of the procedure on the run-time stack, changes made to copies do not percolate back to calling environment. Parameter storage disappears when function call ends and ar is popped off the stack: can change values of local parameters, but doesn"t affect calling environment. Only the return value (if any) is copied back to caller. In c, can cheat by passing pointers: in java, cheat by passing java-style references.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers