Implement memory allocation using AVL