开发者

Question On Stack Permutation

开发者 https://www.devze.com 2023-04-04 14:31 出处:网络
I want to ask that is it necessary that first number in stack permutation should be 1 and last should be n(last number in queue). The examples on web I have se开发者_如何学JAVAen all have first elemen

I want to ask that is it necessary that first number in stack permutation should be 1 and last should be n(last number in queue). The examples on web I have se开发者_如何学JAVAen all have first element 1 and last as n. But using stack permutation algo we can get any number on first place and any on last place.


Permuting a stack should give you a stack which is isomorphic to the original and so the starting state is mostly irrelevant and you could just relabel it as { 1, 2, 3 ... n } so yes, you could start at any number and end at any other.

The web has it from 1 through N because that makes it easier to explain.

0

精彩评论

暂无评论...
验证码 换一张
取 消