Dynamic Programming | Set 33 (Find if a string is interleaved of two other strings)
I found a question in this website and it said "The worst case time complexity of recursive solution is O(2^n).". Therefore, I tried to draw a tree diagram about the worst case this question. I assume that when the length and value of a and b are the same, it will lead to a worst case. It will split into 2 parts till the length of a/b is 0 (using substring).
aa,aa,aaaa
/ \
/ \
a,aa,aaa aa,a,aaa
/ \ / \
/ \ / \
-,aa,aa a,a,aa a,a,aa aa,-,aa
/ / | | \ \
/ / | | \ \
-,a,a -,a,a a,-,a -,a,a a,-,a a,-,a
In this case, it has 13 nodes which is really a worst case, but how to calculate it step by step? IF the length of c increases by 2, it will got 49 nodes. If it increases to a large number, it will be difficult to draw a tree diagram.
Can someone explain this in details, please?