each frame has dierent arguments frame n 1 and the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ean test becomes False   For loop: stop acer going through all items in the “iterable” • Recursion: we stop when we reach the base case • Are we at the base case?   YES, then STOP and return   No: Con5nue by making another recursive call stop the recursion continue recursively 24 8 13 ­11 ­04 When does the recursion stop? • Recursion: we always test if we reached the base case   Yes: STOP and return   No: Con5nue base case recursive call • IMPORTANT: the recursive call must always “get closer” to the base case   In the example, every call uses a smaller value (closer to 1)   If we never reach the base case, we never stop 25 Recursion and the stack ∑N frame 1 gauss(N-1) ∑N-1 frame 2 gauss(N-2) ...   Each frame has different arguments! frame n-1...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online