stack-sortable

Tags: #definition

stack-sortable

Recall a stack (data structure), or a LIFO (last in first out) data structure. Given a permutation, it is stack sortable if there is some sequence of stack operations that sorts the permutation.

Examples

ex: 4 1 3 2 is stack-sortable:
- push 4
- push 1
- pop 1
- 1
- push 3
- push 2
- pop 2
- 1 2
- pop 3
- 1 2 3
- pop 4
- 1 2 3 4

Properties