Pergunta de entrevista da empresa Meta

Given the root of a binary search tree along with a node inside it, find the successor node for the given one.

Respostas da entrevista

Sigiloso

15 de jun. de 2012

In a BST the predecessor is the right-most leaf of the left child and the successor is the left-most leaf of the right child.

Sigiloso

2 de jul. de 2012

And what if there is no right child..? in that case its the parent... So you need to handle both cases..