chap listsstacksand queues bb /now contains original value of /now contains original value of similar effect can be had by using the exclusive-or operator this fact is widely used in computer graphics region of the computer screen can be highlighted by xoring the outline of box around it xoring the box outline second time restores the original contents of the screen stacks the stack is list-like structure in which elements may be inserted or removed from only one end while this restriction makes stacks less flexible than listsit also makes stacks both efficient (for those operations they can doand easy to implement many applications require only the limited form of insert and remove operations that stacks provide in such casesit is more efficient to use the simpler stack data structure rather than the generic list for examplethe freelist of section is really stack despite their restrictionsstacks have many uses thusa special vocabulary for stacks has developed accountants used stacks long before the invention of the computer they called the stack "lifolistwhich stands for "last-infirstout note that one implication of the lifo policy is that stacks remove elements in reverse order of their arrival it is traditional to call the accessible element of the stack the top element elements are not said to be insertedinstead they are pushed onto the stack when removedan element is said to be popped from the stack figure shows sample stack adt as with liststhere are many variations on stack implementation the two approaches presented here are array-based and linked stackswhich are analogous to array-based and linked listsrespectively array-based stacks figure shows complete implementation for the array-based stack class as with the array-based list implementationlistarray must be declared of fixed size when the stack is created in the stack constructorsize serves to indicate this size method top acts somewhat like current position value (because the "currentposition is always at the top of the stack)as well as indicating the number of elements currently in the stack