Page 1 of 1
[Q]Sorting
Posted: Wed Feb 04, 2004 8:23 am
by zizi
Is there an algo to sort a sequence using only two stacks (with Push() and Pop()method ). Pls help me.
Posted: Wed Feb 04, 2004 9:29 am
by Dominik Michniewski
If I think correct not all sequences are possible to sort using two stacks.
Best regards
DM
Posted: Fri Feb 13, 2004 10:15 am
by Riyad
hey ,
it is possible to sort a sequence using two stacks and 2 extra variables . it is very easy to implement bubble sort using only 2 stacks and 2 variables .but to implement it with only 2 stacks [not using any temporary variables ] is impossible . so if u r need , can allow two extra variable i can get the algo for u ......
Bye
Riyad
Posted: Sat Feb 14, 2004 2:07 am
by Larry
Ya, with a constant number of extra variables, 2 stacks is, after all, just a Turing machine, so of course you can sort.. =)