MCPcopy Create free account
hub / github.com/apna-college/Alpha / pushAtBottom

Method pushAtBottom

13_Stacks/Question1.java:4–13  ·  view source on GitHub ↗
(Stack<Integer> s, int data)

Source from the content-addressed store, hash-verified

2//To push an element at the bottom of a stack
3public class Question1 {
4 public static void pushAtBottom(Stack<Integer> s, int data) {
5 if(s.isEmpty()) {
6 s.push(data);
7 return;
8 }
9
10 int temp = s.pop();
11 pushAtBottom(s, data);
12 s.push(temp);
13 }
14
15 public static void main(String args[]) {
16 Stack<Integer> stack = new Stack<>();

Callers 1

mainMethod · 0.95

Calls 3

isEmptyMethod · 0.45
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected