Repository navigation
Expand file tree
/
Copy pathStack_Main.java
More file actions
72 lines (58 loc) · 1.61 KB
/
Copy pathStack_Main.java
File metadata and controls
72 lines (58 loc) · 1.61 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
62
63
64
65
66
67
68
69
70
71
72
/**
*
*/
package com.srikanth.stack;
/**
* @author A
*
*/
public class Stack_Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//Stack Example
Stack stack = new Stack();
stack.push(2);
stack.push(18);
stack.push(25);
stack.push(8);
while(!stack.isEmpty())
System.out.println(" Poping : "+stack.pop());
//Stack Sorter
/*
* System.out.println("Sorting Stack"); StackSorter sortStack = new
* StackSorter(); Stack sortedStack = sortStack.sort(stack);
* while(!sortedStack.isEmpty()) { System.out.print(" " +sortedStack.pop()); }
* System.out.println();
*
* System.out.println("Is original stack empty : " +stack.isEmpty());
*
*
* // Min Stack Example MinStack minStack = new MinStack(); minStack.push(25);
* minStack.push(15); minStack.push(35); minStack.push(5); minStack.push(75);
*
* while(!minStack.isEmpty()) { System.out.println("Min "
* +minStack.getMinimum()); System.out.println("Pop " +minStack.pop());
* minStack.traverse(); System.out.println("*************************"); }
*/
// Stack using Two Queues
StackUsingQueues queueStack = new StackUsingQueues();
queueStack.push(5);
queueStack.push(17);
queueStack.push(4);
queueStack.push(35);
queueStack.pop();
queueStack.push(35);
queueStack.push(45);
System.out.print("Pushing : ");
queueStack.traverse();
System.out.println("Size : " +queueStack.getSize());
System.out.print("Poping :");
while(!queueStack.isEmpty()) {
System.out.print(" " +queueStack.pop());
}
System.out.println();
}
}