height =O(N)
we travel till the Kth level = O(N)
why are are multiplying n*n instead adding n+n ?
height =O(N)
we travel till the Kth level = O(N)
why are are multiplying n*n instead adding n+n ?
we first calculate the height that is O(N)
then we loop from
i = 1 ; i<= H ; i++
this can have at max O(N) time complexity in case of skew tree
then u call the function printKthLevel () which has its own complexity of O(N)
so since both the loops are nested
total complexity is multiplied O(N*N)
thank youuuuuuuuuuuuuuuuuu