<s>
Pancake	B-Algorithm
sorting	I-Algorithm
is	O
the	O
mathematical	O
problem	O
of	O
sorting	B-Algorithm
a	O
disordered	O
stack	O
of	O
pancakes	O
in	O
order	O
of	O
size	O
when	O
a	O
spatula	O
can	O
be	O
inserted	O
at	O
any	O
point	O
in	O
the	O
stack	O
and	O
used	O
to	O
flip	O
all	O
pancakes	O
above	O
it	O
.	O
</s>
<s>
A	O
pancake	B-Algorithm
number	I-Algorithm
is	O
the	O
minimum	O
number	O
of	O
flips	O
required	O
for	O
a	O
given	O
number	O
of	O
pancakes	O
.	O
</s>
<s>
All	O
sorting	B-Algorithm
methods	O
require	O
pairs	O
of	O
elements	O
to	O
be	O
compared	O
.	O
</s>
<s>
For	O
the	O
traditional	O
sorting	B-Algorithm
problem	I-Algorithm
,	O
the	O
usual	O
problem	O
studied	O
is	O
to	O
minimize	O
the	O
number	O
of	O
comparisons	O
required	O
to	O
sort	O
a	O
list	O
.	O
</s>
<s>
For	O
pancake	B-Algorithm
sorting	I-Algorithm
problems	I-Algorithm
,	O
in	O
contrast	O
,	O
the	O
aim	O
is	O
to	O
minimize	O
the	O
number	O
of	O
operations	O
,	O
where	O
the	O
only	O
allowed	O
operations	O
are	O
reversals	O
of	O
the	O
elements	O
of	O
some	O
prefix	O
of	O
the	O
sequence	O
.	O
</s>
<s>
The	O
simplest	O
pancake	B-Algorithm
sorting	I-Algorithm
algorithm	O
performs	O
at	O
most	O
flips	O
.	O
</s>
<s>
In	O
this	O
algorithm	O
,	O
a	O
kind	O
of	O
selection	B-Algorithm
sort	I-Algorithm
,	O
we	O
bring	O
the	O
largest	O
pancake	O
not	O
yet	O
sorted	O
to	O
the	O
top	O
with	O
one	O
flip	O
;	O
take	O
it	O
down	O
to	O
its	O
final	O
position	O
with	O
one	O
more	O
flip	O
;	O
and	O
repeat	O
this	O
process	O
for	O
the	O
remaining	O
pancakes	O
.	O
</s>
<s>
In	O
a	O
variation	O
called	O
the	O
burnt	B-Algorithm
pancake	I-Algorithm
problem	I-Algorithm
,	O
the	O
bottom	O
of	O
each	O
pancake	O
in	O
the	O
pile	O
is	O
burnt	O
,	O
and	O
the	O
sort	O
must	O
be	O
completed	O
with	O
the	O
burnt	O
side	O
of	O
every	O
pancake	O
down	O
.	O
</s>
<s>
It	O
is	O
a	O
signed	O
permutation	B-Algorithm
,	O
and	O
if	O
a	O
pancake	O
i	O
is	O
"	O
burnt	O
side	O
up	O
"	O
a	O
negative	O
element	O
i`	O
is	O
put	O
in	O
place	O
of	O
i	O
in	O
the	O
permutation	B-Algorithm
.	O
</s>
<s>
In	O
2008	O
,	O
a	O
group	O
of	O
undergraduates	O
built	O
a	O
bacterial	B-Application
computer	I-Application
that	O
can	O
solve	O
a	O
simple	O
example	O
of	O
the	O
burnt	B-Algorithm
pancake	I-Algorithm
problem	I-Algorithm
by	O
programming	O
E	O
.	O
coli	O
to	O
flip	O
segments	O
of	O
DNA	O
which	O
are	O
analogous	O
to	O
burnt	O
pancakes	O
.	O
</s>
<s>
The	O
discussion	O
above	O
presumes	O
that	O
each	O
pancake	O
is	O
unique	O
,	O
that	O
is	O
,	O
the	O
sequence	O
on	O
which	O
the	O
prefix	O
reversals	O
are	O
performed	O
is	O
a	O
permutation	B-Algorithm
.	O
</s>
<s>
Chitturi	O
(	O
2011	O
)	O
proved	O
that	O
the	O
complexity	O
of	O
transforming	O
a	O
compatible	O
signed	O
string	O
into	O
another	O
with	O
the	O
minimum	O
number	O
of	O
signed	O
prefix	O
reversals	O
—	O
the	O
burnt	B-Algorithm
pancake	I-Algorithm
problem	I-Algorithm
on	O
strings	O
—	O
is	O
NP-complete	O
.	O
</s>
<s>
The	O
pancake	B-Algorithm
sorting	I-Algorithm
problem	I-Algorithm
was	O
first	O
posed	O
by	O
Jacob	O
E	O
.	O
Goodman	O
,	O
writing	O
under	O
the	O
pseudonym	O
"	O
Harry	O
Dweighter	O
"	O
(	O
"	O
harried	O
waiter	O
"	O
)	O
.	O
</s>
<s>
Although	O
seen	O
more	O
often	O
as	O
an	O
educational	O
device	O
,	O
pancake	B-Algorithm
sorting	I-Algorithm
also	O
appears	O
in	O
applications	O
in	O
parallel	O
processor	O
networks	O
,	O
in	O
which	O
it	O
can	O
provide	O
an	O
effective	O
routing	O
algorithm	O
between	O
processors	O
.	O
</s>
<s>
The	O
problem	O
is	O
notable	O
as	O
the	O
topic	O
of	O
the	O
only	O
well-known	O
mathematics	O
paper	O
by	O
Microsoft	O
founder	O
Bill	O
Gates	O
(	O
as	O
William	O
Gates	O
)	O
,	O
entitled	O
"	O
Bounds	O
for	O
Sorting	B-Algorithm
by	O
Prefix	O
Reversal	O
"	O
and	O
co-authored	O
with	O
Christos	O
Papadimitriou	O
.	O
</s>
<s>
Published	O
in	O
1979	O
,	O
it	O
describes	O
an	O
efficient	O
algorithm	O
for	O
pancake	B-Algorithm
sorting	I-Algorithm
.	O
</s>
<s>
In	O
addition	O
,	O
the	O
most	O
notable	O
paper	O
published	O
by	O
Futurama	B-Application
co-creator	O
David	O
X	O
.	O
Cohen	O
(	O
as	O
David	O
S	O
.	O
Cohen	O
)	O
,	O
co-authored	O
with	O
Manuel	O
Blum	O
,	O
concerned	O
the	O
burnt	B-Algorithm
pancake	I-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
The	O
connected	O
problems	O
of	O
signed	O
sorting	B-Algorithm
by	O
reversals	O
and	O
sorting	B-Algorithm
by	O
reversals	O
were	O
also	O
studied	O
more	O
recently	O
.	O
</s>
<s>
Whereas	O
efficient	O
exact	O
algorithms	O
have	O
been	O
found	O
for	O
the	O
signed	O
sorting	B-Algorithm
by	O
reversals	O
,	O
the	O
problem	O
of	O
sorting	B-Algorithm
by	O
reversals	O
has	O
been	O
proven	O
to	O
be	O
hard	O
even	O
to	O
approximate	O
to	O
within	O
certain	O
constant	O
factor	O
,	O
and	O
also	O
proven	O
to	O
be	O
approximable	O
in	O
polynomial	O
time	O
to	O
within	O
the	O
approximation	O
factor	O
1.375	O
.	O
</s>
<s>
An	O
n-pancake	O
graph	O
is	O
a	O
graph	O
whose	O
vertices	O
are	O
the	O
permutations	B-Algorithm
of	O
n	O
symbols	O
from	O
1	O
to	O
n	O
and	O
its	O
edges	O
are	O
given	O
between	O
permutations	B-Algorithm
transitive	O
by	O
prefix	O
reversals	O
.	O
</s>
<s>
The	O
pancake	B-Algorithm
sorting	I-Algorithm
problem	I-Algorithm
and	O
the	O
problem	O
to	O
obtain	O
the	O
diameter	O
of	O
the	O
pancake	O
graph	O
is	O
equivalent	O
.	O
</s>
<s>
The	O
(	O
Pn	O
)	O
genus	B-Algorithm
of	O
Pn	O
is	O
:	O
</s>
<s>
An	O
example	O
of	O
the	O
pancake	B-Algorithm
sorting	I-Algorithm
algorithm	O
is	O
given	O
below	O
in	O
Python	B-Language
.	O
</s>
<s>
The	O
code	O
is	O
similar	O
to	O
bubble	B-Algorithm
sort	I-Algorithm
or	O
selection	B-Algorithm
sort	I-Algorithm
.	O
</s>
