Jane Street Interview Question

Give the type of a binary tree and an algorithm to compute its depth

Interview Answers

Anonymous

Nov 5, 2010

type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree let depth = function | Leaf -> 0 | Node (_, left, right) -> 1 + max (depth left) (depth right)

6

Anonymous

Jan 26, 2012

rec

2

Anonymous

Jan 26, 2012

heh.. probably why I didn't get the job :P

Anonymous

Oct 4, 2012

You wrote that you declined the offer, not that you weren't given an offer. :P

3