This question evaluates understanding of concurrent data structures, iterator safety, synchronization mechanisms, and reasoning about shared mutable state in multithreaded programs.
You have a binary tree and an inorder iterator implementation that maintains internal traversal state (e.g., a stack). Consider a multi-threaded program where:
How would you design the iterator and surrounding system to be thread-safe under these scenarios?
In your answer, cover: