/* Tree ( NodeIndex[value] ) : 1[3] / \ 2[8] 3[7] / / 4[1] 5[2] \ 6[9] Input (1 is root) : 6 3 8 7 1 2 9 2 L 1 3 R 1 4 L 2 5 L 3 6 R 5 */ #include #include #include using namespace std; struct Node { int value , left , right , parent; int childs; Node() { value=left=right=parent = 0; } }; Node* a; void Inorder( int v ) { if ( v == 0 ) return; Inorder(a[v].left); // L cout< lc+1 ) return Find( r , k-(lc+1)); } int main() { int n; cin>>n; a = new Node[n+1]; for (int i=1 ; i<=n ; i++) cin>>a[i].value; for (int i=1 ; i>f>>c>>p; if (c=='L') a[p].left = f; else a[p].right = f; a[f].parent = p; } CountChilds(1); cout<<"Inorder : "; Inorder(1); cout<<"\n"; cout<<"Find : "; for (int i=1 ; i<=n ; i++) cout<