Java Solution
\nclass Solution {\n    public int numberOfChild(int n, int k) {\n        int index = 0;\n        char direction = \'r\';\n        while (k != 0) {\n           
```\nclass Solution {\n    public int numberOfChild(int n, int k) {\n        int index = 0;\n        char direction = \'r\';\n        while (k != 0) {\n            if (index == n - 1) {\n                direction = \'l\';\n            }\n            if (index == 0) {\n                direction = \'r\';\n            }\n            if (direction == \'l\') {\n                index--;\n            } else {\n                index++;\n            }\n            k = k - 1;\n        }\n        return index;\n    }\n}\n```
['Simulation', 'Java']