Three Employees want to know the average of their salaries. They are not allowed to share their individual salaries.
Question
Three Employees Want to Know the Average of Their Salaries
They are not allowed to share their individual salaries.
Solution
This problem can be solved using a method that allows each employee to share information without revealing their individual salaries. Here's a step-by-step guide:
-
Employee 1 adds a random number (R1) to their salary (S1) and tells the result (S1+R1) to Employee 2. Employee 1 must remember the random number they added.
-
Employee 2 adds their salary (S2) and the number they received from Employee 1 (S1+R1) and adds another random number (R2). They then tell the result (S1+S2+R1+R2) to Employee 3. Employee 2 must remember their random number.
-
Employee 3 adds their salary (S3) to the number they received from Employee 2 (S1+S2+R1+R2) and tells the result (S1+S2+S3+R1+R2) to Employee 1.
-
Employee 1 subtracts their random number (R1) from the number they received from Employee 3 (S1+S2+S3+R1+R2) and tells the result (S1+S2+S3+R2) to Employee 2.
-
Employee 2 subtracts their random number (R2) from the number they received from Employee 1 (S1+S2+S3+R2) and tells the result (S1+S2+S3) to Employee 3.
-
Employee 3 now has the total of all three salaries (S1+S2+S3). They can calculate the average by dividing this total by 3.
This way, each employee only shares a number that includes their salary and a random number, or a number that includes all salaries and a random number. No one ever shares just their salary.
Similar Questions
Define a class Employee. Display the personal salary details of three employeesusing single inheritance
Write a program that would print the information (name, year of joining, salary, address) of threeemployees by creating a class named 'Employee
The arithmetic mean of the following data is: Wages: 200, 210, 220, 230, 240, 250, 260 No. of workers: 5, 15, 32, 42, 15, 12, 4a.205.61b.211.85c.227.92d.234.53
Multiple Choice QuestionPay and benefits make up a worker's _______ plan.Multiple choice question.stock ownershipcommissionsalarycompensation
The ratio of CEO to average employee pay in the United States is about Blank______.Multiple choice question.50 to 1150 to 1350 to 1500 to 1
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.