forked from avinashbest/java-coding-ninjas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueUse.java
More file actions
61 lines (47 loc) · 1.65 KB
/
Copy pathQueueUse.java
File metadata and controls
61 lines (47 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package queues;
public class QueueUse {
public static void main(String[] args) {
System.out.println("Queue using Arrays");
QueueUsingArrays queue = new QueueUsingArrays();
queue.enqueue(10);
queue.enqueue(20);
queue.enqueue(30);
queue.enqueue(40);
System.out.println(queue.front());
System.out.println(queue.dequeue());
System.out.println(queue.front());
System.out.println(queue.dequeue());
System.out.println(queue.front());
System.out.println(queue.dequeue());
System.out.println(queue.isEmpty());
System.out.println(queue.size());
System.out.println("Queue using Linked List");
QueueUsingList<Integer> q = new QueueUsingList<>();
q.enqueue(10);
q.enqueue(20);
q.enqueue(30);
q.enqueue(40);
System.out.println(q.front());
System.out.println(q.dequeue());
System.out.println(q.front());
System.out.println(q.dequeue());
System.out.println(q.front());
System.out.println(q.dequeue());
System.out.println(q.isEmpty());
System.out.println(q.size());
System.out.println("Queue using Stacks");
QueueUsingTwoStacks s = new QueueUsingTwoStacks();
s.push(10);
s.push(20);
s.push(30);
s.push(40);
System.out.println(s.pop());
System.out.println(s.top());
System.out.println(s.pop());
System.out.println(s.top());
System.out.println(s.pop());
System.out.println(s.top());
System.out.println(s.isEmpty());
System.out.println(s.getSize());
}
}