node* levelOrderInput(int* arr ,int i , int n){
if(arr[i] == -1 && i <= n)
return NULL;
if(i>n)
return NULL;
root = new node(arr[i]);
{root->left = levelOrderInput(arr ,root->left, 2i + 1 , n);}
root->right = levelOrderInput(arr ,root->right, 2i + 2 , n);
return root;
}
int main(){
int arr[1000];
int tp = 1;
int i =1 ;
int j = 1;
cin>>arr[0];
while(tp != (2*i +1)){
cin>>arr[j];
if(arr[j] != -1){
j++;
tp++;
i++;
}
else{
tp++;
j++;
}
}
node* temp = levelOrderInput(arr , temp, 0 , tp-1 );
preorder(temp); //if printing preorder , not printing all values.
return 0;
}