0% found this document useful (0 votes)
43 views1 page

A Stack Is A Container of Objects That Are Inserted and Removed According To The

A stack is a data structure that follows the last-in, first-out (LIFO) principle. Elements can only be added or removed from the top of the stack using push and pop operations. A stack is either empty or consists of a top element and the rest of the elements below it, which is also a stack. Stacks have applications such as reversing words, undo/redo functions, parameter and variable storage in compilers, matching braces in syntax checking, and simulating real-world examples like stacks of plates or cars in a garage.

Uploaded by

Ayesha Chaudhry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

A Stack Is A Container of Objects That Are Inserted and Removed According To The

A stack is a data structure that follows the last-in, first-out (LIFO) principle. Elements can only be added or removed from the top of the stack using push and pop operations. A stack is either empty or consists of a top element and the rest of the elements below it, which is also a stack. Stacks have applications such as reversing words, undo/redo functions, parameter and variable storage in compilers, matching braces in syntax checking, and simulating real-world examples like stacks of plates or cars in a garage.

Uploaded by

Ayesha Chaudhry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

 A stack is a container of objects that are inserted and removed according to

the last-in first-out (LIFO) principle. In the push-down stacks only two
operations are allowed: push the item into the stack, and pop the item out of
the stack.
o A stack is a limited access data structure - elements can be added and
removed from the stack only at the top.
o push adds an item to the top of the stack, pop removes the item from the top.
 A stack is a recursive data structure. Here is a structural definition of a Stack:
o a stack is either empty or
o it consists of a top and the rest which is a stack
2. Application :-

 To reverse a word. You push a given word to stack - letter by letter - and
then pop letters from the stack.
 An "undo" mechanism in text editors; this operation is accomplished by
keeping all text changes in a stack.
o Undo/Redo stacks in Excel or Word.
 Language processing :
o space for parameters and local variables is created internally using a stack.
o compiler's syntax check for matching braces is implemented by using stack.
 A stack of plates/books in a cupboard.
 A garage that is only one car wide. To remove the first car in we have to
take out all the other cars in after it.
 Wearing/Removing Bangles.
 Back/Forward stacks on browsers.
 Support for recursion
o Activation records of method calls.

You might also like