diff --git a/QueueLink.java b/QueueLink.java index 9d8f774..5a439b2 100644 --- a/QueueLink.java +++ b/QueueLink.java @@ -3,7 +3,7 @@ // A linked list (LL) node to store a queue entry class QNode { - int key; + int key = 0; QNode next; // constructor to create a new linked list node @@ -78,4 +78,4 @@ public static void main(String[] args) System.out.println("Dequeued item is "+ q.dequeue().key); } -} \ No newline at end of file +} diff --git a/StackDemo.java b/StackDemo.java index c9d9ca7..281ca92 100644 --- a/StackDemo.java +++ b/StackDemo.java @@ -1,7 +1,7 @@ public class StackDemo { private static final int capacity = 3; int arr[] = new int[capacity]; - int top = -1; + int top = 0; public void push(int pushedElement) { if (top < capacity - 1) {