Class Notes (806,817)
CSC148H1 (92)
Paul Gries (18)
Lecture

# jan30c.docx

1 Page
131 Views

School
University of Toronto St. George
Department
Computer Science
Course
CSC148H1
Professor
Paul Gries
Semester
Winter

Description
 Minimum  see stack diagram 1. def minimum(L): 2. ‘’’(list of ints) -> int 3. Return the smallest int in L. L is not modified.’’’ 4. if len(L) == 1: 5. return L[0] 6. else: 7. m = minimum(L[1:]) 8. if m < L[0]: 9. return m 10. else: 11. return L[0] 12. 13.def _min_helper(L, i): 14. ‘’’(list of ints, int) -> int 15. return the smallest int in L[i:]. L is not modified.’’’ 16. if i == len(L) – 1: 17. return L[i] 18. else: 19. # get the smallest item in the rest of the list 20. m = _min_helper(L, i + 1) 21. # and compare it to the current item L[i] 22. if m < L[i]: 23. return m 24. else: 25. return L[i] 26. 27.def min2(L): 28. ‘’’(list of ints) -> int 29. Return the smallest int in L. L is not modified.’’’ 30. Return _min_helper(L, 0)  Midterm 1: o Stacks, queues, and their implementations o Classes: __init__, self, creating instance variables o Exceptions, including try and except o Python modules and
More Less

Related notes for CSC148H1

OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.