Consider a class that uses the following variables to implement an array-based stack:
String [ ] s = new String[100];
Int top = -1;//Note top == -1 indicates stack is empty
A method that implements a void push(String x) operation can be written as
A) if (top == s.length-1)
Throw new RuntimeException("Overflow") ;
Top ++;
S[top] = x;
B) if (top == s.length.
Throw new RuntimeException("Overflow".;
Top ++;
S[top] = x;
C) if (top == s.length-1.
Throw new RuntimeException("Overflow".;
S[top] = x;
Top ++;
D) if (top == s.length.
Throw new RuntimeException("Overflow".;
S[top] = x;
Top ++;
Correct Answer:
Verified
Q12: A stack is a container that allows
Q13: In a list implementation of a queue,the
Q14: A stream of cars going through a
Q15: Consider a class that uses the following
Q16: Consider a class that uses the following
Q18: The stack pop operation
A) removes all items
Q19: In an array-based implementation of a stack,an
Q20: The stack peek operation
A) checks a stack
Q21: A stack based on a linked list
Q22: A stack based on a linked list
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents