Week4
The main purpose of this week is to learn recursion. The recursion is defined as "defining something in terms of itself" multiple times to achieve our objectives.
'Nesting depth of list' is an example of the recursion. The nesting depth of list is the number of nested list in the list. For example:
nesting-depth of [1, 2, 3] -> 1
: because a list doesn't include any list. Therefore the depth is 1.
nesting-depth of [1, 3, 5, [3, 4, 3]] -> 2
: because a list include one list. Therefore the depth is 2.
The recursion is difficult for me because this is a new topic for me. The recursion function calls itself in its function body, and all recursion include the base case which tells me when/how to stop the function. Tracing the each step of recursive calls increases complexity therefore it is hard for me.
0 件のコメント:
コメントを投稿