ou may operate on a stack WORK and a temporary stack TEMP (if necessary) to enable its ADT operations of PUSH (S,X), POP (S, X), and EMPTYSTACK (S), where X represents an element/variable to be pushed into or popped out of the stack and S represents a stack. You may also utilise one variable to carry out the procedures if necessary. I Given n different random integers to be pushed into WORK, how can you determine the maximum element pushed into it while ensuring that the items placed in WORK are in decreasing order, with the maximum element beginning at the bottom of the stack? You may utilise a single variable and the temporary stack TEMP. ii) Given an array A[1: n] of different random numbers, how can you extract the array's sorted list using only stacks?
You may operate on a stack WORK and a temporary stack TEMP (if necessary) to enable its ADT operations of PUSH (S,X), POP (S, X), and EMPTYSTACK (S), where X represents an element/variable to be pushed into or popped out of the stack and S represents a stack. You may also utilise one variable to carry out the procedures if necessary.
I Given n different random integers to be pushed into WORK, how can you determine the maximum element pushed into it while ensuring that the items placed in WORK are in decreasing order, with the maximum element beginning at the bottom of the stack? You may utilise a single variable and the temporary stack TEMP.
ii) Given an array A[1: n] of different random numbers, how can you extract the array's sorted list using only stacks?
Step by step
Solved in 2 steps