#!/bin/python3 Complete the 'findParent' function below. The function is expected to…
- User
#!/bin/python3
Complete the 'findParent' function below.
The function is expected to return an INTEGER.
The function accepts INTEGER processNumber as parameter.
def findParent(processNumber): # Write your code here
if name == 'main':
Image 2
- Process Tree
A hypothetical chain of processes is represented as a tree. Processes are numbered starting at 1, incremented by 1. Every process spawns a number of processes equal to its process number. The first node, processNumber 1, spawns 1 process, the second spawns 2 and so on. See the graph below. Given a process number, find the process number of its parent.
Example processNumber = 6
From the diagram, the parent of 6 is 3.
Function Description
Complete the findParent function in the editor below.
Image 3
Function Description
Complete the findParent function in the editor below.findParent has the following parameter(s): int processNumber: the process number to query
Returns:
int: the process number of the parentConstraints:
2 ≤ processNumber < 10^9Input Format For Custom Testing
Sample Case 0
Sample Input
STDIN Function
6 processNumber = 6Sample Output
3Explanation:
Refer to the graph in the problem statement. The child of 1 is 2, children of 2 are 3 and 4. The children of 3 are 5, 6, and 7. Therefore, the process number of the parent process of the given process is 3. - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.