0
What is meant by python can sort collection recursively to any depth ? [Python]
" Python can sort collections that contain collections,working recursively to any depth " I was reading through Programming using Python 3 by Mark Summerfield, when came through the above statement. Even though I understand the working of sorted() function in python, I didn't really get the meaning behind the above statement. Guys help me by pouring your thoughts on the same. An example would help me a lot. Thank you in advance. Happy learning guys. With regards George J Padayatty
3 Answers
+ 1
it means with the help of stack...
python can recuresively sort any collection upto it's base condition...
unless it's stack gets filled
+ 1
def printMove (to, fr):
'''Prints the moves to be executed'''
print 'move from ' + str (fr) + ' to ' + str (to)
def towers (n, fr, to, sp):
if n == 1:
printMove (to, fr)
else:
towers (n-1, fr, sp, to)
towers (1, fr, to, sp)
towers (n - 1, sp, to, fr)
towers (3, 'fr', 'to', 'sp')
0
Can you illustrate with an example showing the ability of sorting in depth.
PRAMOD JANA