Sunday, 1 October 2017

JAVA : COLLECTION : 8 : Implementation : SingleLinkedList, Stack, Queue implementation

JAVA : COLLECTION : 8 : Implementation : SingleLinkedList, Stack, Queue implementation

Same singleLinkedList implementation can be used for all.



Assume requimrement is to implement the Stack and find maximum number, if i ask stack.maxNum() it should return maximum number.

Logic : In Node class -> have one maxValue.

class Node<T>{

    T value;
    Node<T> next;
    int maxValue;

}



No comments:

Post a Comment