Question: where is the mistake in this code ? /* Write a method is Sorted that accepts a stack of integers as a parameter and returns

where is the mistake in this code ?
/* Write a method is Sorted that accepts a stack of integers as a parameter and returns true if the elements in the stack occur in ascending * (non-decreasing) order from top to bottom, and false otherwise. That is, * the smallest element should be on top, growing larger toward the bottom. An empty or one-element stack is considered to be sorted. When your method returns, the stack should be in the same state as when it was passed in. In * other words, if your method modifies the stack, you must restore it before returning. You may use one queue or stack (but not both) as auxiliary storage. Your solution should run in O(N) time, where N is the number of * elements of the stack. public boolean isSorted(Stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
