Problem · Math
Parent Process Number
Learn this problemProblem statement
Processes are arranged in a tree and numbered starting from 1 in the order they are created.
- Process
ncreates exactlynchild processes. - Child processes are numbered sequentially as they are created.
You are given a process number processNumber, where processNumber > 1.
Determine the parent process number of this process.
Function
getParentProcessNumber(processNumber: int) → intExamples
Example 1
processNumber = 6return = 3Suppose processNumber = 6.
The source diagram highlights process 6 and its parent process 3:
2343567
Process 3 creates child processes 5, 6, and 7, so the parent process number of 6 is 3.
Constraints
2 ≤ processNumber ≤ 10^9