in this code im taking level order input as given and printing the tree in preorder.
Please check the code for level order input.
Level order input
@akshatkaush hey apka level order input ka logic galat hai ,use queue based approach in place of this recursion to take level order input,here is code for reference:
Dry run this code ,you will get it.