Problem 2
- Base case: for a leaf node
leaf
,leaf.in = 1, leaf.ex = 0
- IH: for node
v
with leavesu1..uk
, assumeui.in, ui.ex
is correct - IS: for node
v
,- Case including:
VC
includingv
does not requireu1..uk
to be included, but including it may be more minimal. IH guaranteesui.in, ui.ex
is correct so take the minimum - Case excluding:
VC
excludingv
requires all ofu1..uk
to be included, so in that case sum all theui.in
values to guarantee counting all cases where children are included
- Case including:
- Time complexity:
Problem 3
-
Part 1:
- Base case: a length-1 string is a palindrome
- IH1: substring is a palindrome
- IS1: then if , the string is a palindrome
- IH2: substring is not a palindrome
- IS2: then the string cannot be a palindrome
-
Part 2:
- Base case: If the string is a palindrome, then it is the minimum palindromic split of count 1
- IH: palindromic substring count has been computed correctly from all proper substrings of
- IS: the minimum palindromic substring if is the minimum of the sums for
-
Thus proved
-
Part 1 span: as filling a 2-d array with calculation per subarray
-
Part 2 span: as filling a 2-d array with calculation per subarray
-
⇒ Total time complexity: