Given a binary tree, we are supposed to find the ancestors of a particular node. An ancestor is a node that is present in the upper layer of a given node. Since the problem revolves around binary trees, a particular node can have atmost 2 children so the ancestor of any given node will be its parent node and the ancestor of the parent node will be its parent node (grandparent node for the particular node in question). We will be printing the ancestors of a particular node until we reach the root...
Published on March 10, 2021 08:17