Computers and Technology

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() {...}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:00, paige1614
When you collaborate or meet with a person or group online, it is called
Answers: 1
image
Computers and Technology, 22.06.2019 14:40, coryowens44
For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. after converting to the postfix expression, the program should evaluate the expression from the postfix and display the result. what should you submit? write all the code in a single file and upload the .c file. compliance with rules: ucf golden rules apply towards this assignment and submission. assignment rules mentioned in syllabus, are also applied in this submission. the ta and instructor can call any students for explaining any part of the code in order to better assess your authorship and for further clarification if needed. problem: we as humans write math expression in infix notation, e. g. 5 + 2 (the operators are written in-between the operands). in computer's language, however, it is preferred to have the operators on the right side of the operands, ie. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix write a program that takes an "infix" expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % ( example infix expression: (7-3)/(2+2) postfix expression: 7 3 2 2 result: rubric: 1) if code does not compile in eustis server: 0. 2) checking the balance of the parenthesis: 2 points 3) incorrect postfix expression per test case: -2 points 4) correct postfix but incorrect evaluation per test case: -i points 5) handling single digit inputs: maximum 11 points 6) handling two-digit inputs: 100 percent (if pass all test cases)
Answers: 3
image
Computers and Technology, 22.06.2019 17:30, cesargarcia17671
Type the correct answer in the box. spell all words correctly. under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 3
image
Computers and Technology, 22.06.2019 19:00, trintrin227
In he example code, what does the title attribute create? a tool tip an element a source a markup
Answers: 1
Do you know the correct answer?
Suppose that you are asked to modify the Stack class to add a new operation max() that returns the c...

Questions in other subjects:

Konu
Mathematics, 29.01.2021 21:10
Konu
Mathematics, 29.01.2021 21:10