Write a method splitstack that takes a stack of integers as


Problem

Write a method splitStack that takes a stack of integers as a parameter and splits it into negatives and non-negatives. The numbers in the stack should be rearranged so that all the negatives appear on the bottom of the stack and all the non-negatives appear on the top. In other words, if after this method is called you were to pop numbers off the stack, you would first get all the nonnegative numbers and then get all the negative numbers. It does not matter what order the numbers appear in as long as all the negatives appear lower in the stack than all the non-negatives. You may use a single queue as auxiliary storage. For example, if the stack stores [3, -5, 1, 2, -4] , an acceptable result would be [-5, -4 , 3, 1, 2].

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a method splitstack that takes a stack of integers as
Reference No:- TGS02780541

Expected delivery within 24 Hours