Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

What is problem escalation?

Answered: 1 week ago

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago

Question

b. What groups were most represented? Why do you think this is so?

Answered: 1 week ago