1)reversal of stack..go to following link..On 10/24/11, swadhin jaiswal <jaiswal....@gmail.com> wrote:
> dear friends..
> on saturday we have discussed algorithm of 3 imp. questions related
> to stack and queue..i am gonna attach for these codes..
>
> 1)reversal of stack..go to following link..
> http://www.geeksforgeeks.org/archives/6921
>
> 2)sort a stack..
> void sort(stack)
> {
> type x;
>
> if (!isEmpty(stack)) {
> x = pop(stack);
> sort(stack);
> sorted_insert(x, stack);
> }
> }
>
> void sorted_insert(x, stack)
> {
> type y;
>
> if (!isEmpty(stack) && top(stack) < x) {
> y = pop(stack);
> insert(x, stack);
> push(y, stack);
> } else {
> push(x, stack);
> }
> }
>
> 3)queue using 2 stack..
> http://www.geeksforgeeks.org/archives/5009
>
>
>
> *we have already discussed the implementations of these functions..just go
> thru link for code...
>
> *
>
--
Sent from my mobile device
--
With regards
.
.
.
Rupali Kesarwani