Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
Garbage collector needs to iterate (may be DFS or BFS) and then build a graph for objects which are pointing to each other (may be using shared_ptr) using shared_ptr (original objects ) and weak_ptr (for objects which are pointing to original object). So if original objects goes away it can be deleted, because other objects which are pointing to it will be weak_ptr (which don;t increment reference count).
Perform simple graph traversal either DFS or BFS(you can do it even in parallel)
- gstepanov@griddynamics.com September 29, 2013