Verbally describe how you would implement an algorithm that tracks charged particles in a 2D space. What data structures would you use? How would you calculate their positions as they interact?
Sigiloso
I provided a basic answer about making a class that tracks xy position and charge for each particle. Updates would be performed by looping over each other particle for each particle and calculating a delta movement in xy position. I was asked what the "big O" complexity of this approach would be and said O(n^2). I was then asked for ways in which I could improve this to which I replied you could set a maximum distance between particles, outside of which you would not consider charge effects. When asked about what structures I would use to implement this I could not think of anything. The answer the interviewer was looking for was "quadtree" (I had never heard of this before).