A little backstory: It has been a really long time since I've coded in C (a year. Jumping back into this is really overwhelming.
I need some advice on implementation. Could someone could explain how you would go about designing this? I understand the concept of the problem, but feel lost as to how to even start implementation.
Here are the constraints:
The Input (Given to the algorithm):
The number of computers in the network, designated as N. Assume that the computers are named 1, 2.. up to N.
A log consisting of a list of triples (C1, C2, t). In each triple, C1 and C2 are computer names and t is a timestamp. If (C1, C2, t) appears in the log, then it means that C1 and C2 communicated with each other at time t. (t will always be an integer >= to 0)
There is a computer, CBad, which is the name of the computer where the malware was first introduced. There is also a timestamp, tBad, which is time at which malware was introduced in CBad.
Mechanics of Infection:
If a computer, say C0, is infected and another computer, C1 communicates with C0 at time t, then C will also become infected. (and it will become infected at time t.)
If a computer is infected at time t, then it is infected at any time t1>=t (in other words, it is considered infected at that point and any point afterwards)
The expected output here is a txt file displaying a list of the infected computers as a result of CBad (our patient 0) being infected at time tBad.
We've been discussing minimum spanning tree algorithms (specifically Prims and Kruskals) I'm pretty sure he wants use one of these in solving this problem.
Thoughts so far: My theory so far is that in each list of triplets, C1 and C2 represent two vertices that make up an edge. And the timestamp t represents the cost/weight/whatever of that edge. Somehow I have to build a connected, undirected graph and then run (Kruskal's algorithm?) to find the set?... I just don't know. I feel like an idiot here. :(