I did a phone interview once for Facebook and my interviewer used binary search of an array of integers. I think it is a good thing to use for a first filter because even if you don't know it from memory it is pretty obvious from first principles, and it involves both looping (or recursion) and branching and it is only 10 lines of code. Also there are a few twists you can apply afterwards:
1. Turn it into bisect: return the index at which the searched value should be inserted to maintain the sorted list.
2. Allow any type of array member and require a comparison function provided that returns the standard -1,0,1.
3. Point out that binary search can be used for membership testing with O(log(n)) comparisons where n is array length. Then ask for a data-structure that can perform membership testing in constant time (answer: hash table.)
EDIT: the actual programming was in a shared buffer (something like etherpad). I was mock-interviewing a friend and I had him do it on paper and that worked alright too.
EDIT2: The hardest part about discussing FizzBuzz is avoiding derailing the discussion into FizzBuzz code golf.
#!/usr/bin/env python
for i in range(1,101):
print [i,"Fizz","Buzz","FizzBuzz"][(0==i%3)+2*(0==i%5)]
1. Turn it into bisect: return the index at which the searched value should be inserted to maintain the sorted list.
2. Allow any type of array member and require a comparison function provided that returns the standard -1,0,1.
3. Point out that binary search can be used for membership testing with O(log(n)) comparisons where n is array length. Then ask for a data-structure that can perform membership testing in constant time (answer: hash table.)
EDIT: the actual programming was in a shared buffer (something like etherpad). I was mock-interviewing a friend and I had him do it on paper and that worked alright too.
EDIT2: The hardest part about discussing FizzBuzz is avoiding derailing the discussion into FizzBuzz code golf.