Solution #1: Here is the recursive code,
void printLevel(struct node* root, int k) { if(root == NULL) return; if(k == 1) { printf("%d\n", root->data); return; } printLevel(root->left, k-1); printLevel(root->right, k-1); }
No comments:
Post a Comment