Sie sind auf Seite 1von 6

International Journal of Exploring Emerging Trends in Engineering (IJEETE)

Vol. 02, Issue 05, SEPT- OCT, 2015 Pg. 224-229 WWW.IJEETE.COM

THE REVIEW ON IMPLEMENTATION OF CIRCULAR STACK DATA STRUCTURE

POONAM KATYARE1, MS. NIKITA AWATI2

1
Assistant Professor, MCA Department
Pimpri Chinchwad College of Engineering, University of Pune, India.
2
Research Scholar, MCA Department
Pimpri Chinchwad College of Engineering, University of Pune, India.

ABSTRACT structure is a structured set of variables associated


This paper presents concepts of data structures and with one another in different ways, cooperatively
its use. As new trend in computers have made it defining components in the system and capable of
possible to handle complex problems. being operated upon in the program. Data
Requirements of users are also becoming large and structures are use to identify and develop useful
complex and to solve these problems basic data mathematical entities and operations and to find out
types are not sufficient. Thus there is a need for which type of problems can be solved using these
“Data structure”, which gives more “structure” to entities and operations. They are also used to find
data. These data structures may be a combination representations for the abstract entities such that
or collection of basic data types, with specific their logical relationship is maintained and
properties and operations. This paper also describes implement operations on those entities in a
one of data structure that is stack which provides concrete manner.
push and pop operations with the usual semantics Advantages of data structure includes allowing
also the working of the single stack and multiple information storage on hard disks, provide mean
stack and its applications. It mainly focuses on a for management of large dataset such as databases,
new implementation technique on data structure use for designing efficient algorithms, allowing
called Circular stack. This is an amazing concept data usage and processing data.[3] Only the
where the single stack works as multiple stacks in problem with data structures is only advance users
circular form. can make changes to data structure that is any
problem involving data structure will need experts
KEYWORD help. There are various types of data structures
Data Structure, Stack, Circular stack which include linear and non-linear, static and
dynamic in which the linear data structure include
1. INTRODUCTION arrays, stack and queues.
A stack is one of the linear data structures where
The data structure represents the way of collection of an ordered list of items is found. Stack
organization of data. Once data is stored it can be is an abstract data type which supports semantic
retrieved in many ways. The way of retrieving data way of insertion and deletion. Items are added to
is also provided by data structure.Data structures the list at the top called as Push function and items
plays an important role in programming languages are removed from the top that is Pop Function.
because the particular means to represent an Since the last item added to the list is the first
abstract relationship can have an effect upon the removed from the list, stacks are also known as
efficiency and ease with which elements may be “Last In First Out” (LIFO) lists. A stack is easily
stored, retrieved, and manipulated.[1] A data implemented in an array, requiring only a pointer

ISSN – 2394-0573 All Rights Reserved © 2015 IJEETE Page 224


International Journal of Exploring Emerging Trends in Engineering (IJEETE)
Vol. 02, Issue 05, SEPT- OCT, 2015 Pg. 224-229 WWW.IJEETE.COM

variable to point to the position of the top element 2. DATA STRUCTURE THROUGH STACK
of the stack.
Stack can mostly used to manage the function Structure of stack may be internal stack and
calls. There are various applications of stack like external stack. Generally stack is used for storing
recursion interrupt handling, inter conversion internal function calls in memory In memory
between prefix, infix, and postfix expressions, internally stack of return address of function calls is
matching parenthesis in an expression etc.[2] But mentioned. It is also used to pass parameters to
the stack has the restriction of insertion and functions. There may be a one stack supported by
removal of elements from stack that is in LIFO instruction set called as Single Stack computers.
manner. But this can be overcome by using the
concept of multiple stacks data structure. This stack is used for arithmetic expression
Circular stack has a super-power on the push and evaluation, expression conversion, storing return
pop of the elements in both sides, it mean the front addresses, checking matching parenthesis of
and back (element should pop at the side where it expression.[5] This type of stack is very easily
was actually pushed). The implementation of stack implemented in memory with one block of
is behaves in circular manner. Imagine the memory. But the disadvantaged of this stack is to
operation will flow as a circular queue but without mention parameter list while function calls for each
compromising the stack behaviour. process leads to overhead of maintaining multiple
Diagrammatically representation of circular stack is stacks in memory.
as shown: Circular stack concept used to create stacks
one after the other as per instruction set. This type
of stack is used in all applications of single stack as
storing return addresses, fetching parameters,
expression evaluation and expression conversion
where parameter stack is maintained separately
than address stack. One of the example or
application of circular stack which has two stack
named front stack and back stack working parallel
as single stack. This multiple stack contains some
variables as

Root: This is the first element which will be


In the proposed structure since a circular stack
pointing to the front stack.
actually contains a single collection that then acts
Peak: This is the item pointing to the front stack
as two stacks by the name Front Stack and Back
that is about to pop.
Stack. This means that the array stack occupies the
Deep: This is the item pointing to the back stack
entire front stack or the back stack or any
that is about to pop.
composition of both stacks represented as
The operations involved in circular stack are
Push in Front: That Pushes an item onto the front
stack that may be a top side
Push in Back: That Pushes an item onto back stack
that may be the other side
Pop in Front: This function Pops an item from the
front stack
Pop in Back: This function Pops an item from the
back stack

ISSN – 2394-0573 All Rights Reserved © 2015 IJEETE Page 225


International Journal of Exploring Emerging Trends in Engineering (IJEETE)
Vol. 02, Issue 05, SEPT- OCT, 2015 Pg. 224-229 WWW.IJEETE.COM

3. IMPLEMENTATION OF CIRCULAR Empty else Print Message: Back Empty and


STACK return null

As stack is the data structure which performs the 4. FUNCTIONS CODE:


insertion and deletion of data from same side as
LIFO manner whereas multi stack is the concept Considering the are array of length as Space[5]
where the data is inserted (push) and removed which will have a integer data which is stored using
(deleted) from both the ends. Multi stack contains three integer variables named Root, Peak, Deep
multiple stacks working together as single stack. As assigning Root and Peak to -1 and Deep as 0
the circular stack contains two stacks that are front
stack and back stack which provides the push and 1. 4.1.PUSH FRONT FUNCTION
pop operations from both ends increasing the Here while pushing an element in front stack it
speed. checks whether the Root value (first element of
According to the operations the functions required front stack) and the Deep (element in back stack
in multiple stacks are: that is about to pop) is less than the array size. The
Function of Push Front: element is added in the reverse order as per the
stack rule so that it will also display the elements
In this function if the Root is less than Space according to stack concept. Diagrammatically stack
Length and Deep is less than Space Length Then looks like
loop up to before Deep. Shift item to one place
ahead. Place item on top.
Increment Root and Deep else Print Message: Full

Function Push Back

In this function if the Root is less than Space


Length and Deep is less than Space Length Then
Place the item in the Space at Deep and Increment
Root and Deep else Print Message: Full

Function Pop Front

In this function if Deep is greater than -1 and Root


is not equal to -1 then Top item is the popped item Algorithm for Push Front:
1. Start
of Loop up to Deep element
2. If Root and Deep not less than Space Length

Place space element one step before Empty deep then go to step 9
3. Assign deep-1 to i
space element then Decrement Deep and root and
return popped Item else if Deep - 1 is not equal to //shift data to right next data
4. Assign Space[i] to Space[i+1]
Root. Then Print Message: Front Empty else Print
5. Decrease i by 1
Message: Empty and return null
6. if i>=0 then go to step 4
7. Assign item to Space[0] i.e. shift item to one
Function Pop Back
place ahead
8. Increase Root and Deep by 1
In this function if Deep has value -1 that is less
9. Display “Stack is Full”
than Space Length And Deep as -1 that is greater
10. Stop
than Root then Deep item is the popped items.
Then make the space empty at deep and
decrement deep and return popped Item else if the
value of Root is equals -1 then Print Message:

ISSN – 2394-0573 All Rights Reserved © 2015 IJEETE Page 226


International Journal of Exploring Emerging Trends in Engineering (IJEETE)
Vol. 02, Issue 05, SEPT- OCT, 2015 Pg. 224-229 WWW.IJEETE.COM

Code for Push Front: Code for Push Back:


void Push Front() void Pushback()
{ {
if (Root < 5 && Deep < 5) if(Root == Deep)
{ {
for (int i = Deep - 1; i >= 0; i--) Deep++;
{ }
Space[i + 1] = Space[i]; if (Root < 5 && Deep < 5)
} {
Space[0] = item; Space[Deep] = item;
Root++; Deep++;
Deep++; }
} else
else {
{ cout<<"Full";
cout<<"Full"; }
} }
}

4.2. PUSH BACK FUNCTION

In push back function elements are inserted


from the back side. Initially the location of Deep
and Root is same. As the elements are being
inserted location or the address of Deep goes on
increasing up to the certain limit.

4.3 POP FRONT FUNCTION

This is the function in which element from the


front stack is removed (popped).After the
removal of element from front stack, Root and
Deep location is decreased by one and space in
increased.
Algorithm for Pop Front
Algorithm for Push Back: 1. Start
1. Start 2. If Deep > -1 && Root != -1 then goto 3
2. If Root and Deep not equal then go to step 9 else goto 11
3. Increase Deep by 1 3. Assign Space[0] to popedItem
4. Assign deep-1 to i 4. Assign 0 to i
5. If Root and Deep not less than Space //shift data
Length then goto step 8 5. Assign Space[i+1] to Space[i]
6. Assign item to Space[Deep] 6. Decrease i by 1
7. Increase Deep by 1 7. if i<Deep-1 then goto step 4
8. Display “Stack is Full” 8. Assign 0 to Space[Deep-1]
9. Stop 9. Decrease Root and Deep by 1
10. Display the popped element

ISSN – 2394-0573 All Rights Reserved © 2015 IJEETE Page 227


International Journal of Exploring Emerging Trends in Engineering (IJEETE)
Vol. 02, Issue 05, SEPT- OCT, 2015 Pg. 224-229 WWW.IJEETE.COM

11. if (Deep - 1 != Root) then Display “Front Code for Pop Back
Empty” void PopBack()
else {
Display “Empty” if (Deep -1 < 5 && Deep -1 > Root)
12. Stop {
int popedItem = Space[Deep-1];
Code for Pop Front Space[Deep -1] = 0;
void Pop Front() Deep--;
{ cout<<"\nPoped data="<<popedItem;
if ( Deep > -1 && Root != -1) }
{ else
int popedItem = Space[0]; {
for (int i = 0; i < Deep-1; i++) if (Root == -1)
{ {
Space[i] = Space[i + 1]; cout<<"Empty";
} }
Space[Deep-1] = 0; else
Root--; {
Deep--; cout<<"BackEmpty";
cout<<"\ndata poped="<<popedItem; }
}
} }
else
{
if (Deep - 1 != Root)
{
cout<<"FrontEmpty";
}
else
{
cout<<"Empty";
}
}
}

4.4 POP BACK FUNCTION 5. APPLICATIONS


Depending upon the various types, applications of
Algorithm for Pop Back data structures has been observed. It includes
1. Start queue management, CPU scheduling, Dictionary
2. If Deep -1 < 5 && Deep -1 > Root then in real life scenario. As discussed about the stack
goto 3 else goto 7 its applications include Base conversions,
3. Assign Space[Deep-1] to popped item Evaluation and Conversion of Polish notations,
4. Assign 0 to Space[Deep-1] and Non recursive functions for traversals of
5. Decrease Deep by 1 binary trees [3]. Other than this stack can be used
6. Display popped item in stock market application in which the federal
7. Check if root = -1 then tax laws require investor to compute the profit
Display “Empty” and loss on a LIFO basis, i.e., the most recently
else purchased shares are sold first. The classic Tower
Display “Back Empty” of Hanoi problem is solved by using recursion
concept. An interesting problem is to print out all

ISSN – 2394-0573 All Rights Reserved © 2015 IJEETE Page 228


International Journal of Exploring Emerging Trends in Engineering (IJEETE)
Vol. 02, Issue 05, SEPT- OCT, 2015 Pg. 224-229 WWW.IJEETE.COM

the anagrams of a given word. That is, given an occurred in linear stack. Various applications
N-letter word with all letters different, print all where circular stack is used is discussed in this
the "words" you can form using each letter once, paper.
regardless of whether they are actual words in
some language. The number of such REFERENCES
rearrangements is N-factorial where N is the 1. James Basile. Implementing Data Structures in
number of letters. The problem can be solved in FORTH, The Journal of Forth Application and
several different ways, one of which uses stack. A Research Vol. I . Number 2. Dec. 1983.
simple technique for implementing Or-parallelism 2. Dinesh P. Mehta, Sartaj Sahni, Handbook of
and And-parallelism on distributed machines is DATA STRUCTURES and
solved by stack splitting concept. Stack-splitting APPLICATIONS, ,pages 2-1 to 2-13,
naturally incorporates efficient scheduling and CHAPMAN & HALL/CRC,2005
reduced communication between processors. 3. Joachim Hammer, Markus Schneider, Data
[7].The multi stack implemented using circular Structures for Databases, pages 60-1 to 60-21,
way as circular stack, as data-path chips such as 2001 by CRC Press, LLC
microprocessors and RISC chips become more 4. B. K. Tripathy and S. S. Gantayat, On the
complex, stacks of data-path macros are required implementation of data structures through
to implement the entire data-path. [4] The theory of lists, IJITCS, Vol.2, No.4, August
physical decomposition of a chip into a single 2012
data-path stack, and control logic of random logic 5. Philiph Koopman, Stack Computers the new
as in the past is not always feasible therefore wave, Mountain view press, 1989
special multi-stack structure is used optimization 6. Yan Wang, Implementation of Protocol
techniques and algorithms to partition, place and Stacks, Technical Report IDE0746, June 2007
wire the data-path macros in the form of the 7. Gopal Gupta, Enrico Pontelli, stack splitting:
multi-stack structure, taking into account the A simple technique for implementing Or-
connectivity of the entire chip logic (data-path, parallelism and And-parallelism on distributed
control logic, chip drivers, on-chip memory). machines
Secondly, a novel multi-stack CMOS device 8. Mark Sherman, Andy Hisgen, Jonathan
structure is proposed, the operation of the Rosenberg, Davis Alex Lamb, Functions
structure is fully analyzed for high power CMOS Returning values of Dynamic Size, Feb 1984,
switch design. The structure is also implemented Technical Report PCS-TR86-125
in a standard 0.18-um triple-well CMOS process,
and its performance is fully characterized. The AUTHOR’S BIBLOGRAPHY
proposed switch device incorporates multi-stack Poonam Katyare is Assistant
NMOS switches, one of which has a switch at the Professor at MCA department,
bulk and the others of which have a connection Pimpri Chinchwad College of
between the bulk and the source in order to Engineering, Akurdi Savitribai
provide high power handling capability to the Phule Pune University, India. She
transmit switch side[8]. obtained her M.C.A degree from North
Maharashtra, Kolhapur (2006).She is currently
CONCLUSION doing research in Data Mining and Knowledge
We have given an overview the concept of Discovery. She has published research papers in
circular stack data structure. We tried to focus on various journals and conferences.
the issues related to the design of single data
structures. Our overview clearly illustrates that Nikita Awati is a student of MCA
the design of circular data structures provides department, Pimpri Chinchwad
significant usage of data from multiple ends. College of Engineering, Akurdi
Paper mainly focuses on implementation of Savitribai Phule Pune University,
circular stack with all its operations. Circular India. She is currently doing
stack overcomes memory problems which research in data structure.

ISSN – 2394-0573 All Rights Reserved © 2015 IJEETE Page 229

Das könnte Ihnen auch gefallen