CS1110 Lecture 14: Reminder: our running example
CS1110
Lecture
14,
3/13/2014
CS1110
Lecture 14: Recursion, again
Announcements
Many recursion examples are on the lectures page
These were mostly authored by Prof. Walker White.
? comments in braces are assertions: conditions assumed to hold
if that line is reached. Example:
# {s is empty}
? We are not currently emphasizing the use of assert statements
to enforce preconditions, but they can be quite useful to catch bugs involving accidental precondition violation. Example:
assert type(s) == str, repr(s) + ' is not a string'
(repr gives unambiguous string representation)
Slides by D. Gries, L. Lee, S. Marschner, W. White
Reminder: our running example
def num_es(s):
"""Returns: number of `e's in . Precond: a string"""
# Strategy: break off first character, recur on the rest.
1 if s == '': # base case (no recursion): is empty string
2 return 0
# recursive case: has at least one char
# note this Python trick s[1:] is '' if len(s) ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- recursion and linked lists 3
- jest test coverage report html
- recursion and exceptions
- kirchhoff depth migration using maximum amplitude
- freenas bug 6720
- qgis application bug report 18877
- uct algorithm circle intermediate class recursion part 2
- lab 16 recursion
- problems with recursion tail recursion
- tail recursion
Related searches
- our codes our standards
- timesheet report reminder email sample
- best free bill reminder app
- timesheet reminder email sample
- self reminder quotes
- our thoughts become our actions
- timecard reminder email
- bill pay reminder program
- bill reminder software
- bill pay reminder software
- bill payment reminder app
- bill payment reminder software