can u check where i am wrong
I am getting the O(2^N) ?
In printing the kth level of binary tree after print ‘p’ nodes in level k the remaining nodes is n-p. It is not necessary that p is always equal to 1.
@Ankit003 i didn’t get u bro I think you are saying like if take the value of k > 1 then it will print p node so how to derived the complexity instead of 1 I have to replace with p ?
Think in a way that u have n nodes in the tree so the time take is n and then for printiong the upper bound of the time taken will be n. So complexity should be O(n^2)
@Ankit003 i understand that how to works like for n nodes and again for 1ton 1+2+3+… N then o(n^2) but the things is i m not able to derive the recurrence relation and solve in in mathematical terms problem lies i what to derive the complexity in terms of maths that why i so confused so i understand some of program where just print is done and recursion is happen and derive the complexity but for tree program i m not able to do ??
But u are going to n nodes using recursion so time is O(n)