Hypothesis Induction Base Recursive Method
Hypothesis Induction Base Method :
Better for tree,linked lists,stack using problems.
GOAL here is to make input SMALLER
-
Hypothesis: In this, assume a function with its neceesary input and what we expect in that output.
solveHeightOfBinaryTree(Node root )-> 3 solveHeightOfBinaryTree(Node subnodeAtLevel2) -> 2
-
Induction: This invlolves taking a 1 scenario (easiest one ) and storing result in temp or later to be used later And then process next element. Make sure you make diagrams and think.
-
Base Condition: This can be thought in 2 ways :
- Think of the smallest valid input OR
- Think of the smalled Invalid input