Class Notes (836,325)
CSC148H1 (92)
Paul Gries (18)
Lecture

march12c.docx

1 Page
150 Views

Department
Computer Science
Course
CSC148H1
Professor
Paul Gries
Semester
Winter

Description
 quicksort o on 4000 random data, 0.020 average 1. def quicksort(L): 2. ‘’’(list) -> NoneType 3. Sort the items in L in non-decreasing order.’’’ 4. L [:] = _quicksort(L) 5. 6. def _quicksort(L): 7. ‘’’(list) -> list 8. Return a new list containing the items from L but in non-decreasing order.’’’ 9. 10. if len(L) > 1: 11. left = [k for k in L if k < L[0]] 12. right = [k for k in L if k > L[0]] 13. return _quicksort(left) + [L[0]] + _quicksort(right) 14. else: 15. return L  mergesort o on 4000 random data, 0.046 average 1. def mergesort(L): 2. ‘’’(list) -> NoneType 3. Sort the items in L in non-decreasing order.’’’ 4. L[:] = _mergesort(L) 5. 6. def _mergesort(L): 7. ‘’’(list) -> list 8. Return a new list containing the items from L but in non-decreasing order.’’’ 9. 10
More Less

Related notes for CSC148H1
Me

OR

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.