Juspay Tree of Space Hackathon Part B Thread Safe
- Posted
- 24 May 2025
Summary
I was interviewed by Juspay and asked to design a thread-safe locking system for a tree. I discussed multiple approaches and provided a detailed custom Spinlock implementation, addressing the interviewer's requirement for a library-free solution.
How it went
I was presented with the following problem:
Design a thread-safe locking system for a tree. Each node can be locked by a user only if: None of its ancestors or descendants are locked. Locking/Unlocking must be thread-safe (no race conditions). The solution should efficiently support concurrent operations.
The interviewer shared my Hackathon Part A solution that I had submitted previously. They were specifically looking for a solution without using any libraries and wanted me to break down the algorithm and make it thread-safe. My advice for this round is to just stay calm and communicate clearly. That’s all you can do.
Questions asked (1)
- 01
Design Thread-Safe Tree Locking System
Data Structures & Algorithms · Hard
Design a thread-safe locking system for a tree. Each node can be locked by a user only if: None of its ancestors or descendants are locked. Locking/Unlocking must be thread-safe (no race conditions). The solution should efficiently support concurrent operations.