subject

Suppose that you are asked to modify the Stack class to add a new operation max() that returns the current maximum of the stack comparable objects. Assume that pop and push operations are currently implemented using array a as follows, where item is a String and n is the size of the stack. Note: if x andy are objects of the same type, use x. compareTo(y) to compare the objects x and y public void push String item ) { [n++] = iten; } public String pop { return al--n]; } Implement the max operation in two ways, by writing a new method using array a (in 8.1), or updating push and pop methods to track max as the stack is changed (in 8.2). Q8.1 Implement method maxi 5 Points Write a method max() using Out) space and Oin) running time. public String max() {...} Enter your answer here Q8.2 Update push() and popo 5 Points Write a method max() using On) space and 011) run time. You may update the push and pop methods as needed public void push {...} public String pop() {...} public String max() {...}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 15:10
Awould be a misconfiguration of a system that allows the hacker to gain unauthorized access, whereas is a combination of the likelihood that such a misconfiguration could happen, a hacker’s exploitation of it, and the impact if the event occurred.
Answers: 3
question
Computers and Technology, 22.06.2019 17:30
1. before plugging in a new device to a computer you should unplug all other devices turn off the computer turn on the computer 2. many of the maintenance tools for a computer can be found in the control panel under administrative tools display personalization
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
What would be the address of the cell, which is at the intersection of the second row and the third column in a worksheet?
Answers: 1
question
Computers and Technology, 24.06.2019 13:50
What does code do? a creates a text box that says "solid black" b creates a black border of any width c creates a black border 1 pixel wide
Answers: 1
You know the right answer?
Suppose that you are asked to modify the Stack class to add a new operation max() that returns the c...
Questions
question
Mathematics, 02.07.2020 14:01
question
Mathematics, 02.07.2020 14:01
question
Computers and Technology, 02.07.2020 14:01
question
Mathematics, 02.07.2020 14:01
question
Mathematics, 02.07.2020 14:01
question
Mathematics, 02.07.2020 14:01
Questions on the website: 13722363