Print Ancestors of a given node in Binary Tree - Java

MEDIUM JAVA

Write a function that prints all the ancestors of the key in the given binary tree.

              1
            /   \
          2      3
        /  \
      4     5
     /
    7


Submit Answer

NOTE These questions can be solved in either Java , Python , Rust, C++, Go or ! However, the language intended for these questions is mentioned along with the question on the top. You need to submit the solution file for the autograder to grade the submission. If you are submitting in Java, make sure that the class name is Main (with a capital M)


Optional Java Editor for your use