CSC148H5 Study Guide - Binary Search Algorithm, Local Variable

108 views4 pages
29 Apr 2014
School
Course
Professor

Document Summary

Code/note taken from discussion board which was redistributed. Then trace the next most complex case (plug in known results) """(list of int, can be nested) -> int. Return max number in possible nested list of numbers. #never to make a recursive call ? every elemnt has to be an int(no nesting) for element in lst: if isinstance(element, int): #always will be true ( no recursion ) nums. append(element) else: nums. append(rec_max(element)) return max(nums) Tracing recursion that you should do( refer to the code above) Once the for loop is done ( it returns the max of the sublist you make) max(nuns) is 24, so 24 is returned. Solve simplest problems first then use these to solve the more complex solutions. (this is how you trace but computer goes top down, biggest more complex cases first then does the simplest ones) Python keeps currently copies of the function. Keeps a stack of currently active function calls.

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

Related Documents