Showing posts with label Node. Show all posts
Showing posts with label Node. Show all posts

Saturday, December 21, 2013

Node & TNode Class declaration for Linked List & Tree

public class Node{
    int data;
    Node next;
    Node prev;
 
    Node(){
        data = 0;
        next = null;
        prev = null;
    }
 
    Node(int p){
        data = p;
        next = null;
        prev = null;
    }
}

public class TNode {

    int data;
    TNode left;
    TNode right;
    TNode parent;

    TNode() {
        data = -999999;
        left = null;
        right = null;
        parent = null;
    }

    TNode(int p) {
        data = p;
        left = null;
        right = null;
        parent = null;
    }
}