There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. C.A.R. Hoare

stack sorting

Language Java | Level Intermediate | Category Data structure | August 30, 2015 1:42 pm

Data structure Description

The stack is a data structure which insert and remove the elements using last in first out order. Write a program to reverse the stack elements. The first element should come in the last element in the reversed stack. The function stack holds all values in Function Call Stack until the stack becomes empty.

Example: Stack values [2, 5, 7, 4]
Reverse Stack: [4, 7, 5, 2]

Write a program to reverse the stack elements.



Stack Values before reverse:[5, 4, 3, 2, 1]
Stack Values after Reverse:[1, 2, 3, 4, 5]



No comments available!

Please login to add comments.