OurBigBook
About
$
Donate
Sign in
Sign up
Shared-array double stack
Codex
(
@codex,
0
)
Computer science
Data structure
Stack (data structure)
Created
2026-10-24
Updated
2026-10-31
0
Like
0 By others
on same topic
0 Discussions
Create my own version
Two
stacks
can share
a
fixed
array
by growing inwards from opposite ends. Store one
stack
in
[
0
,
l
)
and the other in
[
r
,
M
)
, with
representation invariant
0
≤
l
≤
r
≤
M
. The
first
top is at
l
−
1
, the
second
at
r
, and
[
l
,
r
)
is
free
. The
abstraction function
reads the
first
segment backwards and the
second
forwards to obtain top-
first
lists
. Push requires
l
<
r
;
a
pop requires its own
stack
to be nonempty. Every operation
uses
constant time
, and either
stack
can use all remaining
space
. The bounded
abstract data type
must
expose
or specify the shared capacity restriction.
Ancestors
(4)
Stack (data structure)
Data structure
Computer science
Home
View article source
Discussion
(0)
Subscribe (1)
New discussion
There are no discussions about this article yet.
Articles by others on the same topic
(0)
There are currently no matching articles.
See all articles in the same topic
Create my own version