package GeeksforGeeksPractice;

public class _0016PrintAncestorsOfANode {
	static int[] path;
	public static class TreeNode {
		int val;
		TreeNode left;
		TreeNode right;
		TreeNode(int x) { val = x; }
	}
	public static void main(String args[]){
		path=new int[1000];
		TreeNode tn=new TreeNode(50);
		tn.left=new TreeNode(8);
		tn.right=new TreeNode(2);
		tn.left.left=new TreeNode(3);
		tn.left.right=new TreeNode(5);
		tn.right.left=new TreeNode(1);
		tn.right.right=new TreeNode(30);
		getAncestorsOfANode(tn,path,0,30);
	}
	public static void getAncestorsOfANode(TreeNode tn,int[] path,int pathLen,int val) {
		
	}

}

@@ -27,16 +27,44 @@
 ice;%0D%0A%0D%0A
+import java.util.Arrays;%0D%0A%0D%0A
 public c
@@ -660,16 +660,313 @@
 l) %7B%0D%0A%09%09
+if(tn!=null)%0D%0A%09%09%7B%09%0D%0A%09%09%09path%5BpathLen%5D=tn.val;%0D%0A%09%09%09pathLen++;%0D%0A%09%09%09if(tn.val==val)%0D%0A%09%09%09%7B%0D%0A%09%09%09%09System.out.println(Arrays.toString(Arrays.copyOfRange(path,0,pathLen)));%0D%0A%09%09%09%09return ;%0D%0A%09%09%09%7D%0D%0A%09%09%09getAncestorsOfANode(tn.left, path, pathLen, val);%0D%0A%09%09%09getAncestorsOfANode(tn.right, path, pathLen, val);%0D%0A%09%09%7D
 %0D%0A%09%7D%0D%0A%0D%0A

print ancestors of a node redo completed