I got the first 2 parts of this answer now I just need help with the rest. Answe
ID: 3883024 • Letter: I
Question
I got the first 2 parts of this answer now I just need help with the rest.
Answer No 3:
a) int num,
s.pop();
num = s.pop(); // the second element will be removed and stored in num
b) int num;
int first;
first = s.pop();
num = s.pop(); // the second element will be removed and stored in num
//Now push second element again
s,push(num);
s.push(first); // push first again
Explanation / Answer
c
for i = 1 to n-1
s.pop();
end for
num = s.pop;
d
stack newStack
for i = 1 to n-1
tmp = s.pop();
newStack.push(tmp);
end for
num = s.peek();
while not(newStack.isEmpty())
tmp = newStack.pop();
s.push(tmp);
end while
e
while not(s.isEmpty())
num = s.pop();
end while
f
stack newStack
while not(s.isEmpty())
tmp = s.pop();
newStack.push(tmp);
end while
num = newStack.peek();
while not(newStack.isEmpty())
tmp = newStack.pop();
s.push(tmp);
end while
g
stack newStack
while not(s.isEmpty())
tmp = s.pop();
newStack.push(tmp);
end while
for i = 1 to n-1
tmp = newStack.pop();
s.push(tmp);
end for
num = newStack.peek();
while not(newStack.isEmpty())
tmp = newStack.pop();
s.push(tmp);
end while
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.