From last week to this, there are two topics covered -- even more recursion, and trees, which branches
Recursion:
- Base Case: stopping condition
- may have several!!!
- Recursive step: subcall of own function
Trees (Branched):
- Number nodes uncertain
- Arity = max(num children under node)
- Height = max(num level)
- Node -(edge)- children -- grandchildren --etc
- has children [list] == root
- has no children == leaf
- Path: sequence of nodes from a1 ->???->an
- length = num(edge of path)
- Depth: # layers in
- More terminology found here.
- Pre-order:
- node => children
- Post-order
- children => node
- Level-Order:
- Depth by depth
- using WHILE loop
- recursing using call(n-1)
- recursing using queue
Trees (Binary):
- Left/Right = 2 children only
- Subtypes:
- Binary Search Trees: L < N < R
- run time \lceil log_2 numnodes \rceil
- Arithmetic Trees
- data = operation
- leaf = values
- Difference in Traversals:
- in-order: L -> node -> R
- post-order: R -> node -> L
Usable Code:
- all([list of bool] = \forall = for all
- any([list of bool]) = \exists = there exist
- {sets, of, elements}
- unordered
- mutable (unless "frozen set")
- iterable
- considers only value of elements
- ex: dictionary

No comments:
Post a Comment