-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
45 lines (42 loc) · 2.1 KB
/
Copy pathMain.java
File metadata and controls
45 lines (42 loc) · 2.1 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
public class Main {
public static void main(String[] args) {
// 1. ArrayStack Test
// System.out.println("=== Testing ArrayStack ===");
// Stack arrayStack = new ArrayStack(5);
// arrayStack.push(586);
// arrayStack.push(87);
// arrayStack.push(321);
// arrayStack.push(50);
// // System.out.println("Top element : " + arrayStack.peek());
// // // System.out.println("Removing element (pop): " + arrayStack.pop());
// // // System.out.println("Remaining size: " + arrayStack.size());
// // System.out.println("Bottom Element: " + arrayStack.getBottom());
// // System.out.println("Middle Element: " + arrayStack.getMiddle());
// System.out.println("Max Element: " + arrayStack.getmax());
// System.out.println("Min Element: " + arrayStack.getmin());
// System.out.print(arrayStack.toString());
// // arrayStack.reverse();
// // System.out.println("After reversing, Top element : " + arrayStack.peek());
// // System.out.println("After reversing, Bottom Element: " + arrayStack.getBottom());
// 2. LinkedStack Test
System.out.println("\n=== Testing LinkedStack ===");
LinkedStack linkedStack = new LinkedStack();
linkedStack.push(300);
linkedStack.push(200);
linkedStack.push(100);
LinkedStack ls = new LinkedStack();
ls.push(4);
ls.push(3);
ls.push(2);
ls.push(1);
// System.out.println("Top element : " + linkedStack.peek());
// // System.out.println("Removing element (pop): " + linkedStack.pop());
// // System.out.println("Remaining size: " + linkedStack.size());
// System.out.println("Bottom Element: " + linkedStack.getBottom());
// // System.out.println("Middle Element: " + linkedStack.getMiddle());
// System.out.println("Max Element: " + linkedStack.getmax());
// System.out.println("Min Element: " + linkedStack.getmin());
// System.out.print(linkedStack.toString());
System.out.print(linkedStack.merge(ls));
}
}