Microsoft Azure - Bangalore
Anonymous User
3574

I was asked this question in Microsoft for their Azure team based in Bangalore. I was a bit rusty in the answers and could not manage to clear it. Would like to know if peek and isempty operations on stack need locking?

  1. Design a thread-safe stack class. What all operations would you need to lock:

    • push
    • pop
    • peek
    • isempty
  2. What if you design a stack using two queues. How would you implement the locking then?

Comments (3)