I was asked this question in the interview. We have to design this trading system. So say you have placed an order of 20 shares of APPLE. The trade is not yet processed. You place another order of 30 more shares of APPLE. They both go as the same trade. Now there are many such customers like you who are placing such orders. Moreover, the trades such as 20 shares of APPLE and 30 more shared of APPLE would be executed in serialized fashion. Also, there would be multiple threads to execute trades in parallel so that the whole process is fast. What data structure do you recommend for the trade data ?
I suggested arraylist or queue. To this the interviewer replied that if the trade would have to be executed in thread, then one might thread might get the order of 20 shares of APPLE, and the other one gets the order of 30 shares of APPLE. I was not sure of this and so the interview ended abruptly.
Could you please help me with this data structure question?
Aucun commentaire:
Enregistrer un commentaire