• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Quant programming interview questions

Joined
8/5/14
Messages
312
Points
303
I'm currently doing some interviews. Usually kill the math, probability and finance questions. Always struggle with programming questions.

I need some basic/intermediate programming questions for quant interviews for practicing. Please post your questions/sources below. Let's discuss our results! Let's make it any language, probably more C++ or python, or just algorithm design.
 
I'm currently doing some interviews. Usually kill the math, probability and finance questions. Always struggle with programming questions.

I need some basic/intermediate programming questions for quant interviews for practicing. Please post your questions/sources below. Let's discuss our results! Let's make it any language, probably more C++ or python, or just algorithm design.
Here is one from RBC for a mid-level trading desk C++ Engineer:

Assume you have an integer variable i = 1 stored in memory, and assume you have two functions that take the address of that variable and simply increment it by one. Since they take the address, these function's return type might be int or void, won't matter. Now assume these two functions run simultaneously, and there is no lock (atomic mechanism) on variable i, and as a result you take out two values, one of which is incorrect, but clearly there is no obvious error i.e. the program runs smoothly.

How the compiler will flag such error? How the program will know there was something wrong with one of these values?
 
I think the compiler will not see it because it is a run-time race condition(?)
 
I think the compiler will not see it because it is a run-time race condition(?)
The answer I gave was that each function would expect that memory address to contain the value 1, and as a result, one of the functions won't "see" the value 1 cause the other have already incremented it, and that function will "flag an implicit error".
I might be wrong about the compiler flagging it.
 
Back
Top