Saturday, 4 April 2015

Another slog for week 11

    Oops, I just saw the slog requirement for this week, so I decided to write another one.
    Here, I am revising the slog of week 8, where I said there can be another way of writing recursion rather than just  (...(c) for all the c in ...).
The other way, as stated in week 8 slog, is like this:
if root is None:
        pass
    else:
        inorder_visit(root.left, perform)
        perform(root)
        inorder_visit(root.right, perform)
In this way, every time we call on this method, if the node, which is the root of the subtree, is not None, the method will be again call on the left and right of that node in order. Well, it has been a long while since I read that slog. I found that the original way of writing recursion has left me with such deep an impression that it is the only way I can think of when dealing with recursion. I need to practice more on the second way. Also the use of eval and perform is also worth looking back on. I am glad I am reminded to revise my slogs, it is a great way to reinforce my knowledge and prepare for my test. 
   
So long, farewell!
  Dark Fox

No comments:

Post a Comment