[Tutor] about recursion code

Alan Gauld alan.gauld at freenet.co.uk
Tue Dec 7 21:39:21 CET 2004


> def selection_sort(lst,start,end):
>     """sort the lst from selection start to end"""
>     if len(lst)==1:
>         return lst
>     elif lst=="":
>         return ""
>     else:
>         return lst[:start]+selection_sort(lst,start+1,end)

This doesn't appear to do any actual sorting?
And the recursive call always passes in the 
original list so I assume it never terminates?

Alan G.


More information about the Tutor mailing list