Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
cs190c:lab5 [2008/02/09 16:24]
seh
cs190c:lab5 [2008/04/18 11:40] (current)
alint
Line 2: Line 2:
     * Example of recursion: Using VPython to draw an H-tree. {{cs190c:​htree_rec.py|Source code.}}     * Example of recursion: Using VPython to draw an H-tree. {{cs190c:​htree_rec.py|Source code.}}
     * In-Lab Problem: Write a recursive function that takes as one parameter -- a list with nested lists containing integers. ​ Sum up all the elements.     * In-Lab Problem: Write a recursive function that takes as one parameter -- a list with nested lists containing integers. ​ Sum up all the elements.
-       * Here is a solution: {{cs190c:​recsum.py|}} 
        * Hint: You will want to use the following syntax in your program.<​code python>​if type(L) == list:</​code>​        * Hint: You will want to use the following syntax in your program.<​code python>​if type(L) == list:</​code>​
        * Skeleton:<​code python>​def recsum(L):        * Skeleton:<​code python>​def recsum(L):
Line 12: Line 11:
     >>>​ recsum([[1,​[4,​5]],​-4,​[[6,​[7],​[9,​10]],​0]])     >>>​ recsum([[1,​[4,​5]],​-4,​[[6,​[7],​[9,​10]],​0]])
     38</​code>​     38</​code>​
 +
 +===== Sample Solution =====
 +   * Here is a solution: {{cs190c:​recsum.py|}}
 +
 
cs190c/lab5.txt ยท Last modified: 2008/04/18 11:40 by alint
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki