Given the following code, what is minElement before the 1st while loop? O 2 O 1...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given the following code, what is minElement before the 1st while loop? O 2 O 1 O-3 05 Question 24 Given the following code 35 35 //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); int minElement = this.peek(); while(this, numElements>0){ if(this, peek() < minElement) { } } minElement = this.peek(); tmpStack.push(this.pop()); //returns original stack to its initial state while(tmpStack.getNumElements()>0){ this.push(tmpStack.pop()); 3 pts → → X хо X P+ Given the following code 33 34 35 3333 //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); int minElement = this.peek(); while(this.numElements>0){ if(this.peek() < minElement) { minElement = this.peek(); tmpStack.push(this.pop()); 36 37 38 39 40 } 41 42 } 43 44 45 46 47 Structure 48 @ } //returns original stack to its initial state while(tmpStack.getNumElements()>0){ } this.push(tmpStack.pop()); return minElement; 10 stk1: Stack@793 50 public static void main(String[] args) { args: [] 51 52 53 Stack stk1 = new Stack(); stk1: Stack@793 stk1.push( data: 5);| stk1.push( data: -3); 54 stk1.push( data: 1); 55 stk1.push( data: 4); 56 stk1.push( data: 2); 57 System.out.println(stk1.getMinElement()); 58 59 Given the following code, what is minElement before the 1st while loop? O2 Canvas 58 59 } X + What is minElement after the 2nd iteration of the 1st while loop? D 04 O-3 02 O 1 Question 25 Given the following code //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); int minElement = this.peek(); while(this, numElements>0){ if(this.peek() < minElement){ minElement = this.peek(); 3 pts nvas X XO What is minElement after the 4th iteration of the 1st while loop? O-3 O 1 O 4 O 2 D Question 26 Given the following code //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); 3 pts Canvas ← →X X 50-> public static void main(String[] args) { args: [] 51 52 53 54 Stack stk1 = new Stack(); $stk1: Stack@793 stk1.push( data: 5);| stk1.push( data: -3); stk1.push( data: 1); 55 stk1.push( data: 4); 56 stk1.push( data: 2); 57 System.out.println(stk1.getMinElement()); 58 59 } stk1: Stock@793 What would tmpStack.peek() return if you were to call it after the 3rd iteration of the 1st while loop? O 4 O-3 01 02 No new data to saxo Lac 15 Given the following code, what is minElement before the 1st while loop? O 2 O 1 O-3 05 Question 24 Given the following code 35 35 //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); int minElement = this.peek(); while(this, numElements>0){ if(this, peek() < minElement) { } } minElement = this.peek(); tmpStack.push(this.pop()); //returns original stack to its initial state while(tmpStack.getNumElements()>0){ this.push(tmpStack.pop()); 3 pts → → X хо X P+ Given the following code 33 34 35 3333 //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); int minElement = this.peek(); while(this.numElements>0){ if(this.peek() < minElement) { minElement = this.peek(); tmpStack.push(this.pop()); 36 37 38 39 40 } 41 42 } 43 44 45 46 47 Structure 48 @ } //returns original stack to its initial state while(tmpStack.getNumElements()>0){ } this.push(tmpStack.pop()); return minElement; 10 stk1: Stack@793 50 public static void main(String[] args) { args: [] 51 52 53 Stack stk1 = new Stack(); stk1: Stack@793 stk1.push( data: 5);| stk1.push( data: -3); 54 stk1.push( data: 1); 55 stk1.push( data: 4); 56 stk1.push( data: 2); 57 System.out.println(stk1.getMinElement()); 58 59 Given the following code, what is minElement before the 1st while loop? O2 Canvas 58 59 } X + What is minElement after the 2nd iteration of the 1st while loop? D 04 O-3 02 O 1 Question 25 Given the following code //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); int minElement = this.peek(); while(this, numElements>0){ if(this.peek() < minElement){ minElement = this.peek(); 3 pts nvas X XO What is minElement after the 4th iteration of the 1st while loop? O-3 O 1 O 4 O 2 D Question 26 Given the following code //return the smallest element in stack public int getMinElement() { Stack tmpStack = new Stack(); 3 pts Canvas ← →X X 50-> public static void main(String[] args) { args: [] 51 52 53 54 Stack stk1 = new Stack(); $stk1: Stack@793 stk1.push( data: 5);| stk1.push( data: -3); stk1.push( data: 1); 55 stk1.push( data: 4); 56 stk1.push( data: 2); 57 System.out.println(stk1.getMinElement()); 58 59 } stk1: Stock@793 What would tmpStack.peek() return if you were to call it after the 3rd iteration of the 1st while loop? O 4 O-3 01 02 No new data to saxo Lac 15
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below Question 23 2 Before the first while lo... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
By a work sampling study: Observed Data The machine is being used Proportion of manual labour (machine is running and/or (servicing time) T-% machine is random serviced) Allowance Time Proportion of...
-
Booth Sales uses the perpetual inventory system for the purchase and sale of inventory and had the following information available on August 31, 2014: Required 1. Calculate the cost of goods sold and...
-
The file P07_28.xlsx lists the scores of all NFL games played during the 2014 season. Use this data set to rank the NFL teams from best to worst.
-
How would the primordial helium content of the universe have been affected if the present cosmic background radiation temperature was \(27 \mathrm{~K}\) instead of \(2.7 \mathrm{~K}\) ? What about...
-
a. Create a spreadsheet model for this problem and solve it. b. What is the optimal trading plan? c. What is the optimal transaction cost (in equivalent USD)? d. Suppose that another executive thinks...
-
Statement of cash flows-indirect method The comparative balance sheet of Merrick Equipment Co. for December 31, 20Y9 and 20Y8, is as follows: December 31, 20Y9 December 31, 20Y8 Assets Cash Accounts...
-
A fund manager announces that the fund's one-month 95% VaR is 6% of the size of the portfolio being managed. You have an investment of $100,000 in the fund. How do you interpret the portfolio...
-
G (V, X, Y, z) = {M (3, 4, 5, 6, 11, 12, 13, 14) A) Truth table B) H- Map w/ all labels C) optimal sop D) Draw optimal circuit. 0110 O 10
-
An individual buys stock at $40 per share. Many years later, the individual dies when the market value is $60. The estate distributes the shares to a beneficiary when the stock is worth $70. What is...
-
A firm that sells fitness electronic equipment has fixed costs of $510,000 and variable costs per unit of $50. Further $200 per unit. How many units does the firm need to sell to break-even?
-
On what basis are NQ stock options usually taxed when the option has no readily ascertainable fair market value?
-
Breeze Manufacturing agrees to purchase goods from Hawkins Inc. In what situation could Breeze reject a shipment of goods from Hawkins under the perfect tender rule?
-
Why do governmental entities have to report on fiduciary activities by using trust and agency funds? Give an example from an ACFR
-
Find the full text of a recent speech by a public figure. Find the speech on- line and listen to it as you follow along with the text. You may also wish to compare this with excerpts of the speech...
-
Define deferred revenue. Why is it a liability?
-
Jan has two jobs during 2012. One employer withheld and paid FICA taxes on $66,600 of Jan's salary, and the other employer withheld and paid FICA taxes on $44,400 in salary paid to Jan. Calculate the...
-
Deborah purchases a new $30,000 car in 2012 to use exclusively in her business. If Deborah does not elect to expense or take bonus depreciation in 2012 and holds the car until it is fully...
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
Show, for a gas obeying the state equation \[p v=(1+\alpha) \Re T\] where \(\alpha\) is a function of temperature alone, that the specific heat at constant pressure is given by \[c_{p}=-\Re T...
-
An engine working on the constant volume (Otto) cycle has a compression ratio of 6.5 to 1 , and the compression follows the law \(p V^{1.3}=\mathrm{C}\), the initial pressure and temperature being 1...
-
The exhaust gases of a compression-ignition engine are to be used to drive an exhaust gas turbo-supercharger. Estimate the mean pressure ratio of expansion and the isentropic enthalpy drop per kmol...
Study smarter with the SolutionInn App