You are on page 1of 2

2.

0,1,2,3,6,4,7,5
3.
left-skewed tree:
import java.util.*;

class GFG
{

static class Node


{
int key;
Node left, right;
};

static Node newNode(int key)


{
Node temp = new Node();
temp.key = key;
temp.left = temp.right = null;

return (temp);
}

public static void main(String args[])


{
Node root = newNode(1);
root.left = newNode(2);
root.left.left = newNode(3);
}
}
Right Skewed Binary Tree:
import java.util.*;
class GFG
{

static class Node


{
int key;
Node left, right;
};

static Node newNode(int key)


{
Node temp = new Node();
temp.key = key;
temp.left = temp.right = null;

return (temp);
}

public static void main(String args[])


{
Node root = newNode(1);
root.right = newNode(2);
root.right.right = newNode(3);
}
}

You might also like