I have a stack implemented with an array (20 cells) of string objects. There is
ID: 3546645 • Letter: I
Question
I have a stack implemented with an array (20 cells) of string objects. There is an integer variable called Top which holds the index of first open cell on the stack (the top) (example shown below). Write out the pseudocode for a
I have a stack implemented with an array (20 cells) of string objects. There is an integer variable called Top which holds the index of first open cell on the stack (the top) (example shown below). Write out the pseudocode for a "pop" method. Create an "is_empty" method which returns a Boolean value (true for empty, false for not empty), then call it from your pop method.Explanation / Answer
Pop()
{
If(isempty(stack[top]))
System.out.println("");
Else{ system.out.println(stack[top]);
Top--;
}
}
Boolean is empty(int top)
{
If(stack[top]!=null)
Return false;
Else return true;}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.