-
Notifications
You must be signed in to change notification settings - Fork 28
/
DoubleStackDemo.java
72 lines (52 loc) · 1.96 KB
/
DoubleStackDemo.java
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
62
63
64
65
66
67
68
69
70
71
72
package ds_004_stacks_and_queues;
public class DoubleStackDemo {
public static void main(String[] args) {
DoubleStack<Integer> dstack = new DoubleStack<>();
System.out.println("Left isEmpty: " + dstack.isLeftEmpty());
System.out.println("Rigth isEmpty: " + dstack.isRightEmpty());
dstack.pushLeft(10);
dstack.print();
dstack.pushRight(90);
dstack.print();
dstack.pushLeft(20);
dstack.pushLeft(30);
dstack.pushRight(80);
dstack.pushRight(70);
dstack.print();
dstack.pushLeft(40);
dstack.pushLeft(50);
dstack.pushLeft(60);
dstack.pushLeft(70);
dstack.pushRight(65);
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
System.out.println("Popped Left : " + dstack.popLeft());
System.out.println("Popped Right: " + dstack.popRight());
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
System.out.println("Popped Left : " + dstack.popLeft());
System.out.println("Popped Right: " + dstack.popRight());
System.out.println("Popped Left : " + dstack.popLeft());
System.out.println("Popped Right: " + dstack.popRight());
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
System.out.println("Popped Left : " + dstack.popLeft());
System.out.println("Popped Right: " + dstack.popRight());
System.out.println("Popped Left : " + dstack.popLeft());
System.out.println("Popped Right: " + dstack.popRight());
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
System.out.println("Popped Left : " + dstack.popLeft());
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
System.out.println("Popped Left : " + dstack.popLeft());
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
dstack.pushLeft(55);
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
dstack.popLeft();
dstack.print();
System.out.println("Capacity: " + dstack.capacity());
}
}