Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me problem 13 m of the stack is now at the top, the value th value that was second from the bottom is

please help me problem 13
image text in transcribed
m of the stack is now at the top, the value th value that was second from the bottom is now third from bird from the values fronil 4, 5, 6, 7, 8), and we nuk of the stack to the top of the stack and leave the other 3. 2. 11. Notice that the value that was at the bottom of the sh from the bottom is now second from the top, the value that we and that the five values not involved in the shift are now at the botto queue as auxiliary storage. You may assume that the parameter niso ments in the stack. at the bottom of the stack in their origina neter n is 20 and not larger than the numb original order. Uscene han the number of ele 13. Write a method called expunge that accepts a stack of integers as a param ments are in nondecreasing order nondecreasing order from top to bottom, by removing from the stack any element that (s) on top of it. For example, if the stack stores [4, 20, 15, 15, 8, 5, 7, 12 7. 5. 3, and 4 should be removed because each has an element above it w our method should change the stack to store [20, 15, 15, 12, 10, 5, 1]. Notice that ments are in nondecreasing order from top to bottom. If the stack is empty or has just one element Use one queue or stack (but not both) as auxiliary storage. and makes sure that the stack's ele stack any element that is smaller than . 5, 7, 12, 3, 10, 5, 11 ement above it with a larger 11. Notice that now the cle- has just one element, nothing changes. 4. Write a method called reverseFirstk that accepts an integer k and a queue of integers as parameters and reverses the order of the first k elements of the queue, leaving the other elements in the same relative order. For example, if a queue named a stores (10, 20, 30, 40, 50, 60, 70, 80, 90], the call of reverse- Pirst (4, q); should change the queue to store (40, 30, 20, 10, 50, 60, 70, 80, 90). If k isor negative, no change should be made. If the queue does not contain at least k elements, your method should throw IllegalArgumentException. Use one queue or stack (but not both) as auxiliary storage. ed issorted that accepts a stack of integers as a parameter and returns true if the ments in the stack occur in ascending (nondecreasing) order from top hould be on ton orawina la ng (nondecreasing) order from top to bottom. That is, the smallest eleme

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 18th International Conference Dasfaa 2013 Wuhan China April 22 25 2013 Proceedings Part 2 Lncs 7826

Authors: Weiyi Meng ,Ling Feng ,Stephane Bressan ,Werner Winiwarter ,Wei Song

2013th Edition

3642374492, 978-3642374494

More Books

Students also viewed these Databases questions

Question

Identify cures that the government does not regulate

Answered: 1 week ago

Question

Consistently develop management talent.

Answered: 1 week ago

Question

Create a refreshed and common vision and values across Europe.

Answered: 1 week ago

Question

Provide the best employee relations environment.

Answered: 1 week ago