Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void InitialScan (BinNode<Integer> t)
- {
- if (t!=null)
- {
- System.out.println(t.getValue());
- InitialScan(t.getLeft());
- InitialScan(t.getRight());
- }
- }
- public static void InnerScan(BinNode<Integer> t)
- {
- if(t!=null)
- {
- InnerScan(t.getLeft());
- System.out.println(t.getValue());
- InnerScan(t.getRight());
- }
- }
- public static void FinalScan (BinNode<Integer> t)
- {
- if(t!=null)
- {
- FinalScan(t.getLeft());
- FinalScan(t.getRight());
- System.out.println(t.getValue());
- }
- }
- public static void printEven(BinNode<Integer> t)
- {
- if(t!=null)
- {
- if(t.getValue()%2==0)
- System.out.println(t.getValue());
- printEven(t.getLeft());
- printEven(t.getRight());
- }
- }
- public static void printIfBiggerThanFather(BinNode<Integer> t)
- {
- int father = t.getValue();
- if(t!=null)
- {
- if(t.getValue() < father)
- System.out.println(t.getValue());
- printIfBiggerThanFather(t.getLeft());
- printIfBiggerThanFather(t.getRight());
- }
- }
- public static void printBiggerNodes (BinNode<Integer> t)
- {
- if(t!=null)
- {
- if(t.hasLeft() && t.hasRight())
- {
- if(t.getValue()>t.getLeft().getValue() || t.getValue()>t.getRight().getValue())
- System.out.println(t.getValue());
- }
- printBiggerNodes(t.getRight());
- printBiggerNodes(t.getLeft());
- }
- }
- public static int Sum (BinNode<Integer> t)
- {
- int sum = 0;
- if(t!=null)
- {
- sum += t.getValue();
- Sum(t.getLeft());
- Sum(t.getRight());
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement