removed duplciated data-structures

This commit is contained in:
Christian Bender
2018-07-25 16:37:10 +02:00
parent 89b94a8f52
commit c86ba856a8
52 changed files with 75 additions and 30618 deletions

View File

@@ -15,6 +15,7 @@ class StackOfLinkedList {
stack.push(2);
stack.push(3);
stack.push(4);
stack.push(5);
stack.printStack();
@@ -23,6 +24,8 @@ class StackOfLinkedList {
stack.pop();
stack.pop();
System.out.println("Top element of stack currently is: " + stack.peek());
}
}
@@ -75,12 +78,20 @@ class LinkedListStack {
System.out.println("Popped element is: " + temp.data);
}
public int peek() {
if (getSize() == 0) {
return -1;
}
return head.data;
}
public void printStack() {
Node temp = head;
System.out.println("Stack is printed as below: ");
while (temp != null) {
System.out.print(temp.data + " ");
System.out.println(temp.data + " ");
temp = temp.next;
}
System.out.println();
@@ -94,5 +105,5 @@ class LinkedListStack {
public int getSize() {
return size;
}
}