The problem of sorting unknown lists is known. But what about the problem of finding the optimal sort for a known list in a stacked machine? That is, suppose you have the following stack machine:
[4,1,3,2] [] []
That is, there is a place for 3 stacks, and 1 of them is filled with numbers. Also, suppose your stack machine can do 2 movements: move a b(puts the top element aon b) and join a b(puts the stack aon top of the stack b). In this case, the optimal sorting:
move a b
a
b
join a b
move 0 1 move 0 1 move 0 2 join 1 2 move 0 2
The following sequence will be executed:
[4,1,3,2] → [4,1,3] → [4,1] → [4] → [4] → [] [] → [2] → [2,3] → [2,3] → [] → [] [] → [] → [] → [1] → [1,2,3] → [1,2,3,4]
, , ?
, , , , , ( ).
:
, . , . , , , , .
, 0. . move , . join unjoin, . , "" "unjoin-operation", 1. , , 2. , , .
, , , . , , - , .
, , - , . , . , .
, 1 ( ) - . 1 , 1 , , .
, , , . , , . , , , , , .
, , : , , , , , . , , . , , . , , .
, , , , . , , , , .
Source: https://habr.com/ru/post/1612133/More articles:Override serialization of DateTime to string - c #Zoom application by displaying DateTime - c #Why is an overridden virtual function called in the base class at build time? - c ++Upgrading to Vim 7.4 on OS X El Capitan - vimVS 2015 Ошибка "Ссылка на объект не установлена в экземпляр объекта" при создании нового проекта или открытии проекта? - visual-studio-2015Mobile Buy SDK Android - how to add the button "Add Cart" with Quanity (Nos) - android2-dimensional scroll chart for Epg or some schedule in android - androidMemory in Javascript, but with fractions - javascriptHow to perform unittest for floating point outputs? - python - pythonRemoving the default racket reader from the reading table for symbolAll Articles