Create a balanced binary search tree from a stream of integers
问题 I have just finished a job interview and I was struggling with this question, which seems to me as a very hard question for giving on a 15 minutes interview. The question was: Write a function, which given a stream of integers (unordered), builds a balanced search tree. Now, you can't wait for the input to end (it's a stream), so you need to balance the tree on the fly. My first answer was to use a Red-Black tree, which of course does the job, but i have to assume they didn't expect me to