• 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!

Quantitative Interview questions and answers

Greetings everyone,

Here is a question I stumbled upon, it sounds like finite automata and generating functions will be involved but I do not have a solution:
How many times would you expect to see the pattern HHHHHHTTTTTT (6 H's 6T's) in 1,000,000 coin tosses?

It has been my experience that the easier the problem statement, the harder the question really is.
Thanks in advance.
Another way of thinking of this without resorting to too much probability. The HHH....TTT sequence is not unique, in that any other combination of H, T of length 12 should have the same probability of occurring and hence the same expectation. Since we only have 10^6-12+1 possible sets of 12, and a total of 2^12 different H, T combinations of length 12, the probability of each should be (10^6-12+1) / 2^12. Same method, less mathy ;)
 
Correct. Since the sides are from a unit length, we can calculate that any side of the triangle must be strictly less than 1/2. The prob that the length of each stick being less than 1/2 is 50% and this condition must hold for all three of them. Hence I have 1/8


Not totally convinced they are related or merely coincidence but I thought of the semi-circle as follow:
Any two points on a circle will be on the same semi-circle (just connect one point to the center, the second point must be on one of the two semi-circles. Pick the one that contains two points). The problem now becomes finding the probability that the third point is on that same semi-circle. There are only 2 semi-circles to begin with so the chance is 50%

Welcome any opinions since with 1,2 minutes to come up with an answer, there are pretty good chance that I may have big holes in my reasonings. I hope to learn from my mistakes and not to repeat them again in future occasions.
question 5 is just another version of question 4
the correct answer for question 4 is 3/4
therefore the one for question 5 is 1/4
 
Hi guys, I have an interview question..

Start with 10k and play a game where u flip a coin and get 10k if it's heads and lose 10k if it's tails. You do this until you go broke and must always bet 10k. What is the expected number of tosses to go broke?

Anytime I try solve this with simulations or maths I get infinity, which seems strange to me.
 
Hi guys, I have an interview question..

Start with 10k and play a game where u flip a coin and get 10k if it's heads and lose 10k if it's tails. You do this until you go broke and must always bet 10k. What is the expected number of tosses to go broke?

Anytime I try solve this with simulations or maths I get infinity, which seems strange to me.

It is an absorbing Markov chain. There are some pretty neat formulas for computing the expected number of tosses before you go broke.

http://en.wikipedia.org/wiki/Absorbing_Markov_chain
 
Hi,

I quite did not understand your answer of Jeorme question on page 38.
I do not understand why walking with an angle changes anything: if the wall is present an angle less than 45° will send you into the wall making the distance covered longer than if you were walking horizontally. Equally if the wall is absent you will not reach B.

Can anybody help me understand this problem ?
 
1. Find \(x\) if \(x^{x^{x^{\ldots}}}=2\)
let y = x^x^x^...
then, we know y = 2
note that since y denotes an infinite power, it can be re-written as x^y since x^y = x^x^x....
thus, x^y = 2
thus x^2 = 2
so, x = +/- sqrt2


EDIT: fixed quote, also removed incorrect solution for #7
 
Last edited:
I have found this one (interview question for junior quant)

You have to walk from point A to point B 10 times, blindfolded. Every time before you start walking, a fair coin is tossed, and if it comes out heads, a wall in the middle is present (situation 2 below), while if it comes out tails it is the situation one below

junior_researcher.gif

. As you are blindfolded, you do not know if the wall is present or not.
Even though you are blindfolded, you can move in perfectly straight lines towards any point you choose. Can you give a prescription how to walk from A to B so that the total distance you cover is as small as possible? What distance do you expect to cover in those 10 walks?
This one is interesting, and I remember seeing something similar to this in Calc I (without the probability)

Its a minimization problem.

-fair coin being flipped 10 times.
there's going to be 5 "worst case" trips, where we hit our point on the vertical axis (the wall), have to walk the remaining height of the wall, then walk sqrt(2) meters to the opposite point, and 5 "best case" trips, where we only have to walk 2*hypotenuse of the triangle with our point.

Function to minimize: 5*(2*Sqrt(h^2 + 1)) + 5*(Sqrt(h^2 +1) + (1-h) + Sqrt(2))
EDIT: didn't need constraint

I used mathematica:
Minimize[{ 10*Sqrt[h^2 + 1] + 5*(Sqrt[h^2 + 1] + (1 - h) + Sqrt[2])}, {h}]

our point that we are aiming for, h , on the wall should be at 1/(2 Sqrt[2]), for a total distance (using above assumptions) of
5 (1 + 3 Sqrt[2])

Numerically, h= 0.353553, total distance = 26.2132

anyone want to check?
 
Last edited:
I have found this one (interview question for junior quant)

You have to walk from point A to point B 10 times, blindfolded. Every time before you start walking, a fair coin is tossed, and if it comes out heads, a wall in the middle is present (situation 2 below), while if it comes out tails it is the situation one below

junior_researcher.gif

. As you are blindfolded, you do not know if the wall is present or not.
Even though you are blindfolded, you can move in perfectly straight lines towards any point you choose. Can you give a prescription how to walk from A to B so that the total distance you cover is as small as possible? What distance do you expect to cover in those 10 walks?

the answer is 28 meters is the distance expected to be covered in 10 walks under the prescription that every time you walk at 45 degrees to top point of the wall and 45 degrees in towards the B point. this makes a distance of 2.82 meters per walk. and for 10 walks it will be 28.2 meters. if you go by probability then minimum distance is 20 meters and the maximum distance is 40 meters. it could be anywhere in between if you hit the wall every time and then move alone the wall, so wall or no wall, follow the 45 degree path and you will make 2.82 meters distance per walk and for 10 walks 28.2 meter

contact me on jawadwaheed09@gmail.com
 
the answer is 28 meters is the distance expected to be covered in 10 walks under the prescription that every time you walk at 45 degrees to top point of the wall and 45 degrees in towards the B point. this makes a distance of 2.82 meters per walk. and for 10 walks it will be 28.2 meters. if you go by probability then minimum distance is 20 meters and the maximum distance is 40 meters. it could be anywhere in between if you hit the wall every time and then move alone the wall, so wall or no wall, follow the 45 degree path and you will make 2.82 meters distance per walk and for 10 walks 28.2 meter

contact me on jawadwaheed09@gmail.com

The question asks for total distance after 10 walks and coin flips. You are saying that 2*sqrt(2) is the minimal distance one should cover for each walk, regardless of a wall blocking your path or not.

Since a fair-sided coin implies that half of our walks will NOT have a wall, it is wasteful to walk the extra distance. So instead, we are tasked to find a height (call it H) on the wall that will minimize the distance walked while also taking into account the possibility of a wall blocking our path.

The points H, A (or B, depending on orientation) and O (the point where the wall intersect distance between point A and B) form a right triangle, with base = distance between point A (or B) and O = 1 , height = H. Using Pythagoras' theorem,

Hypotenuse = distance we walk to the wall from A or B = Sqrt(1+H^2)

Now, consider these two cases:
1. (Worst case) There is a wall: We must now walk an additional 1-H meters to the top of the wall, and another Sqrt(2) meters from the top of the wall to our endpoint. The distance covered by walking this case is given by the function f:
f(H) = sqrt(1+H^2) + (1-H) + Sqrt(2)

2. (Best case) There is no wall: We need only walk Sqrt(1+H^2) meters to our endpoint. The distance covered by walking this case is given by the function g:
g(H) = 2*sqrt(1+H^2)

So ultimately,we want a find an H large enough to ensure that our additional 1-H meters in our worst case is small, but we also need H small enough so that our distance covered in the best case is minimal. In other words, we want a value of H that will optimally minimize both functions.

Given that a fair-sided coin is flipped each time we walk from point A or B, it is safe to assume that 5 of these walks will have walls and 5 will not. From this, we can determine the total distance covered over 10 walks, which will be the function d:

d(H) = 5*f(H)+5*g(H) = 5*(sqrt(1+H^2) + (1-H) + Sqrt(2)) + 5*(2*Sqrt(1+H^2))

Minimizing d(H) is essentially the same as finding the optimal H that minimizes f(H) and g(H)
simultaneously.

Minimizing d(H), we see that the minimal total distance covered is 26.2132 meters from the height H = 0.353553 meters.

Also: it is worth noting that this H will change with respect to the probability of the coin tosses. For example, if there was a 60% chance of heads,, or a 60% chance of a wall, then we would have 6 worst case scenarios and 4 best case scenarios: in this instance, H= 0.474342 for a total distance of 27.1344 meters.

The picture I'm including considers various outcomes for coin tosses and their impact on H
 

Attachments

  • walktheline.png
    walktheline.png
    35.4 KB · Views: 65
Last edited:
The question asks for total distance after 10 walks and coin flips. You are saying that 2*sqrt(2) is the minimal distance one should cover for each walk, regardless of a wall blocking your path or not.

Since a fair-sided coin implies that half of our walks will NOT have a wall, it is wasteful to walk the extra distance. So instead, we are tasked to find a height (call it H) on the wall that will minimize the distance walked while also taking into account the possibility of a wall blocking our path.

The points H, A (or B, depending on orientation) and O (the point where the wall intersect distance between point A and B) form a right triangle, with base = distance between point A (or B) and O = 1 , height = H. Using Pythagoras' theorem,

Hypotenuse = distance we walk to the wall from A or B = Sqrt(1+H^2)

Now, consider these two cases:
1. (Worst case) There is a wall: We must now walk an additional 1-H meters to the top of the wall, and another Sqrt(2) meters from the top of the wall to our endpoint. The distance covered by walking this case is given by the function f:
f(H) = sqrt(1+H^2) + (1-H) + Sqrt(2)

2. (Best case) There is no wall: We need only walk Sqrt(1+H^2) meters to our endpoint. The distance covered by walking this case is given by the function g:
g(H) = 2*sqrt(1+H^2)

So ultimately,we want a find an H large enough to ensure that our additional 1-H meters in our worst case is small, but we also need H small enough so that our distance covered in the best case is minimal. In other words, we want a value of H that will optimally minimize both functions.

Given that a fair-sided coin is flipped each time we walk from point A or B, it is safe to assume that 5 of these walks will have walls and 5 will not. From this, we can determine the total distance covered over 10 walks, which will be the function d:

d(H) = 5*f(H)+5*g(H) = 5*(sqrt(1+H^2) + (1-H) + Sqrt(2)) + 5*(2*Sqrt(1+H^2))

Minimizing d(H) is essentially the same as finding the optimal H that minimizes f(H) and g(H)
simultaneously.

Minimizing d(H), we see that the minimal total distance covered is 26.2132 meters from the height H = 0.353553 meters.

Also: it is worth noting that this H will change with respect to the probability of the coin tosses. For example, if there was a 60% chance of heads,, or a 60% chance of a wall, then we would have 6 worst case scenarios and 4 best case scenarios: in this instance, H= 0.474342 for a total distance of 27.1344 meters.

The picture I'm including considers various outcomes for coin tosses and their impact on H



Hi There,

Your solution is elegant, thank you very much, you used the software to determine the minimum value of the total distance, and the corresponding value of H, I however, used the calculus method of taking the derivative of the function, putting it equal to zero, and finding the value of the H. thank you...
 
Good brainteasers. Though I think problem 1 is a bit too easy for a real quant interview. Problem 2 can be changed into the following form: x^6 - 64 =0 You can factorize the equation into (x^3-8)(x^3+8) = (x-2)(x^2+2x+4)(x+2)(x^-2x+4). You have two real solutions x=2, -2, and four imaginary solutions.

Or you can use Euler's formula. r*e^(i*theta) = r*cos(theta) + i*r*sin(theta). with r = 2 and incremental angle set to pi/3, you get the same 6 roots.

Also, for number 3, shouldn't the answer be 1 hour and 12 minutes?
If the hour and minute hands meet at 12 o'clock, the two hands meet against after 1.
minute hand moves 6 degrees per minute and hour hand moves 0.5 degrees per minute.
let t be the time in minutes.

t : time in minutes
30+0.5(t-60) = 6t-360
t = 72 (minutes)

Therefore, the two hands meet again at 1:12.

Problem 1 and 6 can be solved by re-iteration. x = sqrt(2), and x=2 for the 6
 
Last edited:
From the Heard on The Street 13th edition, Chapter 2, Question 2.1:
All BS assumptions hold.
q=0, S0= 100, r=0.05, T=1, K=100, sigma=0. What is the European Call worth?

I used the closed BS formula, and got (1-exp(-.05))*100, but the answer is exp(-.05)*5.

Why we can't use the BS formula?
 
From the Heard on The Street 13th edition, Chapter 2, Question 2.1:
All BS assumptions hold.
q=0, S0= 100, r=0.05, T=1, K=100, sigma=0. What is the European Call worth?

I used the closed BS formula, and got (1-exp(-.05))*100, but the answer is exp(-.05)*5.

Why we can't use the BS formula?

In the book, the answer is 5/1.05 not exp(-.05)*5, assuming annual compounding and not continuous compounding.

If we assume continuous compounding both methods yield same result = (1-exp(-.05))*100
 
In the book, the answer is 5/1.05 not exp(-.05)*5, assuming annual compounding and not continuous compounding.

If we assume continuous compounding both methods yield same result = (1-exp(-.05))*100

I just made it continuous compounding to match BS methodology.
In your calculation, how did you get the (1-exp(-.05))*100 as a continuous compound of 5/1.05?
 
I just made it continuous compounding to match BS methodology.
In your calculation, how did you get the (1-exp(-.05))*100 as a continuous compound of 5/1.05?

Volatility of rate of return is 0 and not volatility of price. If volatility is Zero, the rate of return is constant for stock and it is r = 0.05
Price of stock at expiration. 100exp(0.05).
Payoff at expiration = 100exp(0.05) - 100
Payoff now using TVM will give you the answer.
 
Help me:a and b are randomly chosen real numbers in the interval [0, 1], that is both a and b are standard uniform random variables. Find the probability that the quadratic equation x^ 2 + ax + b = 0 has real solutions
 
Hi in your a^2 - 4b^2 did not understand how did the power of 2 for b come.
I think the answer is 1/12 otherwise.
 
Some quant interview
1. You are trapped in a dark cave with three indistinguishable exits on the walls. One of the exits takes you 3 hours to travel and takes you outside. One of the other exits takes 1 hour to travel and the other takes 2 hours, but both drop you back in the original cave through the ceiling, which is unreachable from the floor of the cave. You have no way of marking which exits you have attempted. What is the expected time it takes for you to get outside?

2. You have 1000 coins, one of which is faulty: it has a head on both sides. You randomly draw a coin, and, without examining it, toss it 10 times. As it happens, you get 10 heads in a row. What’s the probability that it’s the faulty one?
 
Back
Top