Question: DO IT ASAP I HAVE NO TIME *** This question will be graded manually by your instructors. *** Collections: The Stack class represents a last-in-first

 DO IT ASAP I HAVE NO TIME *** This question will

be graded manually by your instructors. *** Collections: The Stack class represents

a last-in-first out (LIFO) container of objects. Here is the Stack interface:

DO IT ASAP I HAVE NO TIME

*** This question will be graded manually by your instructors. *** Collections: The Stack class represents a last-in-first out (LIFO) container of objects. Here is the Stack interface: public boolean push(Object x): Pushes (adds) an item on to the top of the stack. public Object pop(): Removes the object at the top of the stack and returns that object as the return value of this function. public Object pecku): Returns the object at the top of the stack without removing it from the stack. public boolean empty: Tests if the stack is empty. Returns true it and only if the stack contains no items; false otherwise. public int search(Object x): Returns the array position where the object is located. Returns - 1 if the object is not in the stack. Below, you are given the "myStack" class, where a stack is implemented using arrays. The class has 3 data declarations. "theStack is the Array capacity at myStack, and 'top' is an integer denoting the first empty space in the stack. Initially, when the stack is empty the value of top is 0, stack contains one element that element is stored in Array's oth position, and the value of the top is 1. denoting the first empty space in the st Complete the mystack class by writing Java code into appropriate blanks below. (Hint: The push method for the stack class is already implemented, as a hint for you.) x A B 1 ***Don't delete the given source code. Please only write your answers. *** public class myStack private Object( theStacks private int capacity: private int top: I/Constructor: Creates an empty stack public mystack(int capacity) theStack new Object(capacity]: thi.capacity - Capacity: top:0; 1 public boolean empty // Write your code here public Object popol // Write your code here. public boolean push(Object) 1 A B 1 = ? ***Don't delete the given source code. Please only write your answers." public class myStack private object[] theStack; private int capacity: private int top: f/Constructor: Creates an empty stack public myStack(int capacity) theStack = new Object(capacity]: this.capacity=capacity: top = 0; public boolean empty I/Write your code here 1 public Object popot // Write your code here. public boolean push(Object) theStack(top] -X top- ) public int search(Object) [ // Write your code here ] public Object peeko // Write your code here of objects. Here is the Stack interface: che stack. rack and returns that object as the return value of this function. ck without removing it from the stack. e it and only if the stack contains no items; false otherwise. object is located. Returns -1 if the object is not in the stack. ng arrays. The class has 3 data declarations. "theStack is the Array where elements of the stack is kept. "capacity denotes the maximum allowed in the stack. Initially, when the stack is empty the value of top is o, denoting the first empty space in the stack is the Array's oth position. If the and the value of the top is 1, denoting the first empty space in the stack is the Array's 1st position. below. nt for you.) *** This question will be graded manually by your instructors. *** Collections: The Stack class represents a last-in-first out (LIFO) container of objects. Here is the Stack interface: public boolean push(Object x): Pushes (adds) an item on to the top of the stack. public Object pop(): Removes the object at the top of the stack and returns that object as the return value of this function. public Object pecku): Returns the object at the top of the stack without removing it from the stack. public boolean empty: Tests if the stack is empty. Returns true it and only if the stack contains no items; false otherwise. public int search(Object x): Returns the array position where the object is located. Returns - 1 if the object is not in the stack. Below, you are given the "myStack" class, where a stack is implemented using arrays. The class has 3 data declarations. "theStack is the Array capacity at myStack, and 'top' is an integer denoting the first empty space in the stack. Initially, when the stack is empty the value of top is 0, stack contains one element that element is stored in Array's oth position, and the value of the top is 1. denoting the first empty space in the st Complete the mystack class by writing Java code into appropriate blanks below. (Hint: The push method for the stack class is already implemented, as a hint for you.) x A B 1 ***Don't delete the given source code. Please only write your answers. *** public class myStack private Object( theStacks private int capacity: private int top: I/Constructor: Creates an empty stack public mystack(int capacity) theStack new Object(capacity]: thi.capacity - Capacity: top:0; 1 public boolean empty // Write your code here public Object popol // Write your code here. public boolean push(Object) 1 A B 1 = ? ***Don't delete the given source code. Please only write your answers." public class myStack private object[] theStack; private int capacity: private int top: f/Constructor: Creates an empty stack public myStack(int capacity) theStack = new Object(capacity]: this.capacity=capacity: top = 0; public boolean empty I/Write your code here 1 public Object popot // Write your code here. public boolean push(Object) theStack(top] -X top- ) public int search(Object) [ // Write your code here ] public Object peeko // Write your code here of objects. Here is the Stack interface: che stack. rack and returns that object as the return value of this function. ck without removing it from the stack. e it and only if the stack contains no items; false otherwise. object is located. Returns -1 if the object is not in the stack. ng arrays. The class has 3 data declarations. "theStack is the Array where elements of the stack is kept. "capacity denotes the maximum allowed in the stack. Initially, when the stack is empty the value of top is o, denoting the first empty space in the stack is the Array's oth position. If the and the value of the top is 1, denoting the first empty space in the stack is the Array's 1st position. below. nt for you.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!