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;
    }
}

No comments:

Post a Comment