MCPcopy Create free account
hub / github.com/Lakhankumawat/LearnCPP / insert

Function insert

S-Stack/ReverseStack.cpp:13–28  ·  view source on GitHub ↗

function that inserts an element into stack.

Source from the content-addressed store, hash-verified

11
12//function that inserts an element into stack.
13void insert(char x)
14{
15
16 if(st.size() == 0) st.push(x);
17
18 else
19 { //take out the topmost element, pop it and recursively call the function
20 char a = st.top();
21 st.pop();
22 insert(x);
23
24
25 // when inserted at the bottom then push items in stack
26 st.push(a);
27 }
28}
29
30// function that reverses the given stack
31void reverse()

Callers 1

reverseFunction · 0.70

Calls 4

sizeMethod · 0.45
pushMethod · 0.45
topMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected