1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
solmaris [256]
3 years ago
8

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() {...}
Computers and Technology
1 answer:
Advocard [28]3 years ago
7 0

Answer:

Following are the code to the given points:

Explanation:

For point 8.1:

public String max()//defining a method max

{

   String maxVal=null;//defining a string variable that holds a value

   for(int x=0;x<n;x++)

   {

       if(maxVal==null || a[i].compareTo(maxVal)>0)//defining if blok to comare the value

       {

           maxVal=a[i];//holding value in maxVal variable

       }

   }

   return maxVal;//return maxVal variable value

}

For point 8.2:

public void push(String item)//defining a method push that accepts item value in a parameter

{

       a[n]=item;//defining an array to hold item value

       if(n==0 || item.compareTo(maxVals[n-1])>0)//use if to comare item value

       {

               maxVals[n]=item;//holding item value in maxVals variable

       }

       else

       {

               maxVals[n]=maxVals[n-1];//decreasing the maxVals value

       }

       n++;//incrementing n value

}

public String pop()//defining a method pop

{

       return a[--n];//use return value

}

public String max()//defining a method max

{

       return maxVals[n-1];//return max value

}

  • In the first point, the max method is declared that compares the string and returns its max value.
  • In the second point, the push, pop, and max method are declared that works with their respective names like insert, remove and find max and after that, they return its value.
You might be interested in
How to get someone off your best friends list without blocking them
Paraphin [41]

Answer:

Which website

Explanation:

6 0
2 years ago
The data-linking feature that allows Internet users to skip directly from a highlighted word to a related file in another comput
tamaranim1 [39]

Answer:

Hypertext

Explanation:

According to my experience on information technology, I can say that based on the information provided within the question the term being mentioned is called Hypertext. Like described in the question this term refers to a software system which shows as a highlighted piece of text that allows a user to immediately be taken to another system with information associated with the highlighted text that was clicked.

If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Read 2 more answers
A type of backlight technology most commonly used in modern laptop devices is called____________.
alekssr [168]

Answer:

LED is the correct answer for the following question.  

Explanation:

LED is a display that is used in the Laptop screen which is a type of blacklight technology. Blacklight technology is a technology that is used to increase readability when the light is low.

An LED display is used in a modern laptop. It is a flat panel display. Its brightness is so high and allows a user to use it in the presence of the sunlight. It is designed in 1962 for the first time.

The above question asked about a blacklight technology that is used in a laptop device which is the LED display used in a modern laptop. Hence the answer is LED

7 0
3 years ago
Your organization recently deployed a Windows domain controller with Active Directory. All the domain OU users need to run the s
liberstina [14]

<u>Normally windows end user can login 3 ways as follow:</u>

1. End user can Login as local account where user has not connected or even connected to local Area network LAN.

2. Next user can login into cloud accounts nothing but hot mail  accounts

3. Login to windows domain controller where end user should connect to LAN.

Purpose of installation of Windows domain controller with Active Directory is to keep trace and keep log history activities.

Due to windows domain controller with Active Directory end user desktop or laptop has control on software access also.

Every time when end user login on windows domain controller a small modified is executed whenever is required. It is not going effort the workstation performances.

Note: - Domain severs should be POWER on first.

5 0
3 years ago
Do software engineers save millions of dollars in usa
SCORPION-xisa [38]
Yes. They make a lot of money. So eventually after saving your Money, you will make a least 1 million dollars or more.
4 0
2 years ago
Other questions:
  • Write down a recurrence relation for this version of QuickSort, and solve it asymp-totically. Show your work. Assume that the ti
    13·1 answer
  • n macOS, what launch point provides access to almost all the settings needed to administer a macOS system?
    5·1 answer
  • ________ is a software that interprets java bytecode.
    12·1 answer
  • An app builder has created a report for sales people to view records from the custom object, some users have complained that the
    8·1 answer
  • If a user wants to change one small section of the formatting of a document and leave the rest the same, which process should be
    14·1 answer
  • Where should you click to edit an existing formula?
    12·2 answers
  • A number of related records that are treated as a unit is called
    6·1 answer
  • The overall visual look of a chart in terms of its graphic effects, colors, and backgrounds is the:
    5·1 answer
  • PLZ help
    5·1 answer
  • In _________, the process requests permission to access and modify variables shared with others. a) entry section b) critical se
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!