• 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

I think the problem can be restated as a Bernoulli experiment where the only thing that matters is that Bob tosses a 6 on the third or fourth trial. That Sue and Bob take turns does not matter. What matter is to account for the fact that Bob is either the first to start the experiment or second (hence success on the third or fourth toss, resp). P(Success) = 1/6. An appropriate distribution for this problem would be the geometric one, hence,

P(Bob wins on second turn) = (5/6)^2 * 1/6 + (5/6)^3*1/6

I cannot understand your answer.

I would suggest writing a MATLAB simulation (very easy).
 
I cannot understand your answer.

I would suggest writing a MATLAB simulation (very easy).

You are right...I see where I have gone wrong. I really should have read the question more carefully! What do I take away from this? Never drink and read Quantnet (after 12am) :D
 
any idea for this question

you have a deck of 52 cards, and you keep taking pairs of cards out of the deck. if a pair of cards are both red, then you win that pair; if a pair of cards are both black, then I win that pair; if a pair of cards has one red and one black, then it's discarded. If, after going through the whole deck, you have more pairs than I do, then you win $1, and if I have more pairs than you do, I win $1. What is the value of this game in the long run?
 
you have a deck of 52 cards, and you keep taking pairs of cards out of the deck. if a pair of cards are both red, then you win that pair; if a pair of cards are both black, then I win that pair; if a pair of cards has one red and one black, then it's discarded. If, after going through the whole deck, you have more pairs than I do, then you win $1, and if I have more pairs than you do, I win $1. What is the value of this game in the long run?

You haven't said what happens if we have an equal number of pairs.
Did you mean that no one wins anything in this case?
 
Parabola's Interesting (& Useful) Property

We've all heard of the special property that parabolas have; namely, when a ray in the interior of a parabola and parallel to the parabola's axis of symmetry hits the parabola it then is such reflected that it passes through the focal point of the parabola. Now the proof of this is not too difficult and is a good exercise in analytic geometry (and maybe a bit of calculus). A parabola in the plane is defined as follows: Given a straight line and a point outside the line in a plane, the set of all points equidistant from both the line and the point is called a parabola.

But here's a question: Is parabola unique in this regard among all axially symmetric curves? In other words, if a curve has the reflection property noted above, then is that curve necessarily a parabola?
 
Univorm RVs Produced From Other RVs

Let [[.]] denote greatest integer value function.

Define RV Yn=(X1+X2+...+Xn) - [[X1+X2+...+Xn]] for any n in {1,2,3,...}.

Now it is not a trivial task to demonstrate that Y1, Y2, Y3, ... is a sequence of uniform RVs over [0,1] if the X1, X2, X3, ... are iid uniform RVs over [0,1].

Questions:

(1) Is the sequence Y1, Y2, Y3, ... a sequence of INDEPENDENT uniform RVs over [0,1] if X1, X2, X3, ... are iid uniform RVs over [0,1]?

(2) For what kinds of iid RVs X1, X2, X3, ... is the sequence Y1, Y2, Y3, ... a sequence of uniform RVs over [0,1]?

(3) Pose some questions of your own regarding the relationship between the Ys and Xs.
 
Toy-Containing Cereal Boxes Generalized

The following is inspired by a problem posted by vkaul under the title "hardest question I got in an interview!" in the Education forum.

Cereal boxes of a top brand contain toys out of a set of n different types of toys, where n is a known fixed number. Each box contains precisely k toys, where k is a known fixed number. Find the expected value of the number of cereal boxes which a person will need to buy in order to complete the collection of n toys if

(i) each type of toy has an equal probability to be in a box regardless of the other toys in the same box,

(ii) each toy has an equal probability to be in a box but it is different from the all other toys in the same box.
 
Roll A Die Till You Get All Six

An unfair (biased) die is such that the number k has the probability k/21 to come up, where k is in {1,2,3,4,5,6}. On average how many times does one have to roll the die until all six numbers come up?
 
A Guard Dog's Area of Coverage

One end of a guard dog's leash is tied to the corner of a rectangular building of dimensions AxB (where A<B), and the other end is tied to the dog. Find the total area that the guard dog can cover if the length of the leash is L. Express the answer as an explicit function of A, B and L.
 
interview question

Hi all,
I have an interview questions that I didn't get, and would like to get some advise from you guys

a straddle option with strike = 5, which one is more expensive, with underlying asset having
1.) discrete integer price from 0 to 10 (0, 1,2..10)
2.) continuous price from 0 to 10

Thanks all.
 
That sounds more like a homework question.
 
a programming question I was asked:

You are to play a game with a 52 card deck, with 26 red cards and 26 black. Before each card is drawn you can bet any amount of your bankroll including 0 on a certain color turning up. (Payout is standard that is on a bet of x you get 2x back if correct and 0 if wrong) Now you play until all 52 cards are dealt. But this isn't your money but your friends who will beat you up if you are reckless with it. So you are very risk averse and are only interested in strategies that guarantee a certain amount.

So the question is: What is the maximum amount that you can guarantee?

Just describe the algorithm as I never calculated the actual number.
 
Notice a key term is "guarantee".

You are always guaranteed to know the color of the last card. And there is no way of knowing in advance the sequence of colors for the first 51 cards.

Now imagine that the cards are shuffled a thousand times and just by pure chance, unbeknownest to you, they line up in the constant order of red/black/red/black... all the way through. In this situation you are liable to call the wrong color if you take a guess on each of the first 51 cards. So, because you demand a guaranteed win, then your only best bet is to wait until all the first 51 cards are revealed, and then just call the correct color of the 52-nd card.

But, maybe we need to re-phrase the question as: What strategy will maximize the winning amount ON AVERAGE? Of course, the strategy is to be dynamic, in the sense that every call and amount wagered depends on the information gathered up until and including the last card was revealed.

Suppose so far b black cards and r red cards have been revealed and you are about to make the (b+r+1)-th call before the (b+r+1)-th card is revealed. Without loss of generality, suppose b<=r. Then, of course, you'd make a black call for the (b+r+1)-th card. This strategy, when repeated every time, will maximize the winnings ON AVERAGE, without guaranteeing a final positive win.

A question: Following the strategy just described without concern for a gurananteed final positive win, what is the amount of total winnings ON AVERAGE?
 
You can actually do better than waiting till the last card to double you initial bankroll.
 
Show me how.

First note: given any amount of cards it only makes sense to bet on the color that makes up a greater portion of the deck

Now Define T(n, r) to be the amount we can guarantee for n cards with r being red given an initial bankroll of $1.

Obviously T(n , 0) = 2^n since we can double our bankroll each bet
and T(n,n) = 2^n also

Now the case T(2,1) = 2 since we do not bet on the first card and double up on the last card and we can not do better here.

The next simple case is for 3 cards
obviously T(3,0) = T(3,3)= 8
but what about T(3,1) (which is also T(3,2))

there are 3 possibilities for deck order: (we bet black on the first card always since there are 2 black cards)
1.) R B B
2.) B R B
3.) B B R
say we bet x on the first card

In case 1 we get: (1-x) * 4
In case 2 and 3 we get: (1+x)*2

so the amount we can guarantee with 3 cards is: max min {(1-x)*4} {(1+x)*2)} where x in [0,1]

when drawn graphically we can see that x = 1/3 as the optimal bet and hence for 3 cards we can guarantee: 8/3 which is better than 2


The solution can be generalized and calculated in O(nr) time using dynamic programming where we just have an array 52 x 26 and fill it top down using the relation:


if( r >= n/2)
T(n,r) = max min {(1+x) T (n-1,r-1)} {(1-x) T (n-1, r)} where x in [0,1]

else
T(n,r) = max min {(1+x) T (n-1,r)} {(1-x) T (n-1, r-1)} where x in [0,1]


I never coded this up so I don't know the actual number
 
First note: given any amount of cards it only makes sense to bet on the color that makes up a greater portion of the deck

Now Define T(n, r) to be the amount we can guarantee for n cards with r being red given an initial bankroll of $1.

Obviously T(n , 0) = 2^n since we can double our bankroll each bet
and T(n,n) = 2^n also

Now the case T(2,1) = 2 since we do not bet on the first card and double up on the last card and we can not do better here.

The next simple case is for 3 cards
obviously T(3,0) = T(3,3)= 8
but what about T(3,1) (which is also T(3,2))

there are 3 possibilities for deck order: (we bet black on the first card always since there are 2 black cards)
1.) R B B
2.) B R B
3.) B B R
say we bet x on the first card

In case 1 we get: (1-x) * 4
In case 2 and 3 we get: (1+x)*2

so the amount we can guarantee with 3 cards is: max min {(1-x)*4} {(1+x)*2)} where x in [0,1]

when drawn graphically we can see that x = 1/3 as the optimal bet and hence for 3 cards we can guarantee: 8/3 which is better than 2


The solution can be generalized and calculated in O(nr) time using dynamic programming where we just have an array 52 x 26 and fill it top down using the relation:


if( r >= n/2)
T(n,r) = max min {(1+x) T (n-1,r-1)} {(1-x) T (n-1, r)} where x in [0,1]

else
T(n,r) = max min {(1+x) T (n-1,r)} {(1-x) T (n-1, r-1)} where x in [0,1]


I never coded this up so I don't know the actual number

Thank you very much! Great and convincing answer! Really well done!
 
Find The Number ...

Given a natural number N, let P(N) denote a function that is the product of all factors of N.

For example, for N=6, the factors are 1,2,3,6, so the product of these factors P(6)=36. Or, P(9)=27.

Questions:

1. Is P one-to-one? That is, if M and N are two unequal natural numbers, then can we have P(M)=P(N)?

2. Given P(N), find N.
 
I'll give a go... P is one-to-one. So P(N) is a product of the factors, and each of the factors has a unique prime factorization. We can decompose P(N) into a product of these prime factorizations, but then we won't be able to permute it into different factors, so P(N)=P(M) => N = M.

I would use this line of thinking to find N, given P(N). All of the factors of N are obviously contained in P(N), but the list of factors of P(N) might contain extraneous factors. For example, if M=10, then the list of factors is 1,2,5,10 and P(M)=100. But if we look at the list of factors for P(M), we get 1, 2, 4, 5, ..., (I'm lazy), ..., 100. This might not be the most efficient way to do it, but it will get the job done. I would start building a list of the factors of P(N), and testing each factor as it came up by looking at the product of all of its factors. Some for loops and some mods should do the trick nicely.

If anyone wants to see code, I'd be happy to oblige.
 
N Cars On A One-Way Highway

Quote:
(Another interview question)

You have N cars that are all traveling the same direction on an infinitely long one-lane highway. Unfortunately, they are all going different speeds, and cannot pass each other. Eventually the cars will clump up in one or more traffic jams.

In terms of N, what is the expected number of clumps of cars?

Solution (1):

***Please see Solution (2) below as a separate post. It is much simpler and faster!***

It is understood that although the word "jam" is used in the statement of the problem, the cars never come to a stop. What happens is that when a faster-moving car reaches a slower-moving car, then both cars move at the speed of the slower-moving car. Note that the actual speed of the cars is immaterial to the solution; what matters is that given any two distinct cars, one of them moves slower than the other.

We translate the above problem to an equivalent one as follows:

Let X(1), X(2), ...,X(N) be a sequence of random variables over the set {1,2,...,N}, with X(i) different form X(j) if i is different from j. Here X(i) represents the speed of car i, and the set {1,2,...,N} represents the speeds of the cars. We can suppose that the cars, represented by C(1),C(2),...,C(N), are in the order given and move in the East-West (Left To Right) direction. So, if X(N)=1, then there will be exactly one clump, all moving at the speed X(N)=1 of car C(N). If X(N-1)=1, then there will be exactly two clumps, one of which is the right-most car C(N) -- a single-car clump -- having speed greater than 1. The other clump, consisting of (N-1) cars, will be moving behind the car C(N) at the speed X(N-1)=1.

For any k in {1,2,...,N}, the probability P{X(k)=1}=(1/N). If X(k)=1, then all the cars C(1) through C(k) will form a clump and will be moving at the speed X(k)=1. Looking at the cars C(k+1) through C(N), we see that their speeds are all different and any of them can have any of the speeds with equal probability. So, it makes no difference what we assume to be the actual speeds of these cars, what matters is that they be different. So, we may just as well assume the speeds for the cars C(k+1) through C(N) to be {1,2,...,(N-k)}. Also we can rename these cars as A(1),...,A(N-k), so that A(i)=C(k+i) for i in {1,2,...,(N-k)}.

Now let E(N) denote the expected number of clumps of N cars.

It is obvious that E(0)=0.

If X(k)=1, then we get 1 clump consisting of the first k cars (i.e., C(1),...,C(k)). Depending on the value of k, we get on average E(N-k) clumps for the remaining (N-k) cars that are moving ahead of the first k cars.

So,

E(N) = 1 + SUM{(P{X(k)=1})*E(N-k); [k,1,N]}.

Simplifying, we get:

E(N) = 1 + SUM{(1/N)*E(N-k); [k,1,N]},

or

E(N) = 1 + (1/N)*SUM{E(k); [k,1,(N-1)]}.

We can easily show that E(N)=(1/N)+E(N-1), with E(0)=0.

From which we get the Harmonic series E(N)=(1)+(1/2)+(1/3)+...+(1/N).
 
Back
Top