Question

) Consider Java's Stack class, and its five standard stack operations: push, pop, peek, isEmpty, and...

  1. ) Consider Java's Stack class, and its five standard stack operations: push, pop, peek, isEmpty, and clear. Complete the two unfinished methods. Do not modify any other parts of the class.

      

       // Looks at the top two elements of the stack, and removes and returns the larger

       // of the two elements from the stack, returning the other element to the stack.

       // For example, if the stack, from the top, is 8 10 7 2 15 5, then the method will

       // return 10, and the resulting stack will be 8 7 2 15 5, because 10 was the larger

       // of the top two values.

// Assume the stack contains at least two elements.

       public int popBig(Stack<Integer> stack) {


       }

// Given a stack of integers, containing exactly two occurrences of 99,

       // return a count of how many numbers are in the stack between the two 99s,

       // not counting the 99s themselves. For example, if the stack contained, from the top,

       // 4 7 99 8 6 3 99, then the method should retun 3 because there are 3 numbers

       // 8, 6, and 3, that are between the 99s. Note that if the two 99s appear side by

       // side, then the method should return 0.

       public int countBetween99(Stack<Integer> nums) {

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
) Consider Java's Stack class, and its five standard stack operations: push, pop, peek, isEmpty, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT