BST implementation - memory allocation in stack and heap