Question
Problem B Spreading News You are the manager of a company, and you want all of your employees to be notified of an important news
Problem B Spreading News You are the manager of a company, and you want all of your employees to be notified of an important news item as quickly as possible. Your company is organized in a tree-like structure: each employee has exactly one direct supervisor, no employee is his own direct or indirect supervisor, and every employee is your direct or indirect subordinate. You will make a phone call to each of your direct subordinates, one at a time. After hearing the news, each subordinate must notify each of his direct subordinates, one at a time. The process continues this way until everyone has heard the news. Each person may only call direct subordinates, and each phone call takes exactly one minute. Note that there may be multiple phone calls taking place simultaneously. Compute the minimum amount of time, in minutes, required for this process to be completed. Employees will be numbered starting from 1, while you will be numbered 0. Furthermore, every supervisor is numbered lower than his or her direct subordinates.s Input First line of the input contains T the number of test cases. Each test case contains an integer N (1 N 70) denoting the number of employees in your company including you. Next line contains N-1 integer. The ith integer denote the supervisor of ith employee(i starts from 1) . Look you(employee 0) do not have any supervisor. Output For each test case output the minimum amount of time, in minutes, required.
Sample Input
5
3
0 0
5
0 0 2 2
9
0 0 1 1 2 2 3 4
5
0 1 2 3
7
0 1 2 3 3 3
Sample output
2
3
4
4
6
Problem B Spreading News You are the manager of a company, and you want all of your employees to be notified of an important news item as quickly as possible. Your company is organized in a tree-like structure: each employee has exactly one direct supervisor no employee is his own direct or indirect supervisor, and every employee is your direct or indirect subordinate. You will make a phone call to each of your direct subordinates, one at a time. After hearing the news, each subordinate must notify each of his direct subordinates, one at a time. The process continues this way until everyone has heard the news. Each person may only call direct subordinates, and each phone call takes exactly one minute. Note that there may be multiple phone calls taking place simultaneously. Compute the minimum amount of time, in minutes, required for this process to be completed. Employees will be numbered starting from 1, while you will be numbered 0. Furthermore, every supervisor is numbered lower than his or her direct subordinates.s Input First line of the input contains T the number of test cases. Each test case contains an integer N (1 N s 70) denoting the number of employees in your company including you. Next line contains N-1 integer. The i'th integer denote the supervisor of i'th employeeli starts from 1). Look you(employee 0) do not have any supervisor Output For each test case output the minimum amount of time, in minutes, required Sample In Sample ou 0 0 22 0 01 1 2 23 4 0 1 23 0 1 2 3 3 3 Problem B Spreading News You are the manager of a company, and you want all of your employees to be notified of an important news item as quickly as possible. Your company is organized in a tree-like structure: each employee has exactly one direct supervisor no employee is his own direct or indirect supervisor, and every employee is your direct or indirect subordinate. You will make a phone call to each of your direct subordinates, one at a time. After hearing the news, each subordinate must notify each of his direct subordinates, one at a time. The process continues this way until everyone has heard the news. Each person may only call direct subordinates, and each phone call takes exactly one minute. Note that there may be multiple phone calls taking place simultaneously. Compute the minimum amount of time, in minutes, required for this process to be completed. Employees will be numbered starting from 1, while you will be numbered 0. Furthermore, every supervisor is numbered lower than his or her direct subordinates.s Input First line of the input contains T the number of test cases. Each test case contains an integer N (1 N s 70) denoting the number of employees in your company including you. Next line contains N-1 integer. The i'th integer denote the supervisor of i'th employeeli starts from 1). Look you(employee 0) do not have any supervisor Output For each test case output the minimum amount of time, in minutes, required Sample In Sample ou 0 0 22 0 01 1 2 23 4 0 1 23 0 1 2 3 3 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started