Bloomberg Senior engineer phone screen(NYC)- Token ring implementation
Summary
I had a phone screen for a Senior Engineer role at Bloomberg in NYC, where I was asked an Object-Oriented Design problem involving a token ring implementation. Unfortunately, I struggled to understand the problem during the interview due to poor explanation and ultimately failed.
Full Experience
Was expecting a standard algo question but was asked this OOD style problem in phone screen for Senior engineer. I couldn't understand it in the interview as the interviewer had did a very poor job of explaining it. And as expected failed the interview. Was able to figure it out later.
You are given two classes 'RingManager' and 'RingElement' .
You need to implement a ring of elements where:
- Only one element holds the "token" at any time
- The first created element starts with the token
- Calling release() passes the token to the next element in the ring
- The ring is circular — releasing from the last element returns the token to the first
Example Test Cases and asserts that needed to pass.
RingManager ringtest; RingElement piece1 = ringtest.create(); assert(piece1.hasToken()); // First element gets tokenRingElement piece2 = ringtest.create(); assert(piece1.hasToken()); // Still with piece1
piece2.release(); assert(!piece1.hasToken()); assert(piece2.hasToken()); // Token moved to piece2
piece2.release(); // Token goes back to piece1 (circular)
This was the template given in the interview.
#include <vector> #include <memory>class RingManager;
class RingElement { private:
public: bool hasToken(...) const; void release(...); };
class RingManager { private:
public: RingManager(){}
RingElement create(); bool hasToken(...); void release(...);
};
Interview Questions (1)
Token Ring Implementation (OOD)
You are given two classes 'RingManager' and 'RingElement' .
You need to implement a ring of elements where:
- Only one element holds the "token" at any time
- The first created element starts with the token
- Calling release() passes the token to the next element in the ring
- The ring is circular — releasing from the last element returns the token to the first
Example Test Cases and asserts that needed to pass.
RingManager ringtest; RingElement piece1 = ringtest.create(); assert(piece1.hasToken()); // First element gets tokenRingElement piece2 = ringtest.create(); assert(piece1.hasToken()); // Still with piece1
piece2.release(); assert(!piece1.hasToken()); assert(piece2.hasToken()); // Token moved to piece2
piece2.release(); // Token goes back to piece1 (circular)
This was the template given in the interview.
#include <vector> #include <memory>class RingManager;
class RingElement { private:
public: bool hasToken(...) const; void release(...); };
class RingManager { private:
public: RingManager(){}
RingElement create(); bool hasToken(...); void release(...);
};