English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

can anyone give me the c code for implementing two stacks using single array?
and code for peforming insertions and deletions at both ends of a double ended queue,plz????

2006-08-13 00:41:49 · 4 answers · asked by bhavya_too cool 1 in Computers & Internet Programming & Design

4 answers

there's an example here:
http://www.macs.hw.ac.uk/flex/BScCS/ds1/activity5.html

2006-08-13 02:11:11 · answer #1 · answered by Ibraheem G 2 · 0 0

ARR [===============]
0 1 2 3 4 5 6 ... N-1 N

Suppose you have just an array ARR of size N, then you could implement two stacks by assuming that the two stacks grow inwards from either side of the array, the left stack growing 0, 1, 2 .. while growing, while the right-stack pointer becoming N, N-1, N-2 while storing new elements. While pushing or popping, one needs to make sure that over-flow and under-flow conditions are checked.
HTH.

2006-08-13 19:07:12 · answer #2 · answered by swami060 3 · 1 0

Here is the link to my code (though in java) - here for 2 stacks in 1 array.

2014-03-06 08:40:37 · answer #3 · answered by kinshuk c 1 · 0 0

specific i will bt what form of help u necessary pls specify Stacks artwork on LIFO theory LIFO:- final In First Out 2 substantial operations are POP & PUSH Array implementation of Stack is extremely undemanding.

2016-12-14 05:07:34 · answer #4 · answered by ? 3 · 0 0

fedest.com, questions and answers