EASY - MEDIUM
HASHING , MAPPING
Find the numbers of programmes which is need to terminate by the OS.
The OS will terminate those programmes which are running on more than 2 machines. so,for achieving this ,
you need to count programmes and their occurrences on different machines,so, you can use hashing or MAPPING
technique to do this.
N1,N2,N3,N4,N5 are the different machines.
and the running programmes are
N1 = 2 3 4 5
N2 = 3 4 5
N3 = 3 2
N4 = 3 4
N5 = 2 3 4
so, program 2 occur for 3 times.
program 3 occur for 5 times.
program 4 occur for 4 times.
program 5 occur for 2 times.
so,programmes 2,3,4 occurs more than two times.
so,Number of programmes are 3.
Hence 3 is the answer.
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.