Here is my code:-
I have done above code but it is not giving expected output
hey @priya_Jain
void printAtLevelK(node *root,int k)
{
if(root==NULL)
{
return;
}
if(k==0) //k==0 here instead of k==1
{
cout<<root->data<<" ";
return;
}
printAtLevelK(root->left,k-1);
printAtLevelK(root->right,k-1);
return;
}
Also your input was incorrect to built tree ,it should be :
1 2 4 6 -1 -1 7 10 -1 -1 11 -1 -1 5 8 -1 -1 9 -1 -1 3 -1 -1