1- given the definition of the class 'StackArray' to implement a stack using arrays. Complete the implementation of methods- push, pop, and peek.
public class StackArray {
int[] s=new int[5];
int top=-1;
public boolean isempty( ){
return top == -1;
}
public boolean isfull( ){
return top == s.length-1;
public void push(int e) {
public int pop( ) {
public int peek( ) {
2- Write Java code to:
a: Create a Deque object containing all integers from 1 to 20.
b: Display the front and rear elements
c: Display all elements in reverse order.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here