Goseeko blog
  • Home
  • Engineering
    • Civil
    • Electronics
    • Computers
  • Science
    • Chemistry
    • Maths
    • Physics
  • Commerce
  • Arts
  • E-Learning
  • Career
  • Exams
  • Scholarships
  • Hiring News
  • Goseeko- Smart Study Material
@2021 - All Right Reserved. Designed and Developed by PenciDesign
Top Posts
Goseeko launches its own certifications for engineering and...
Online certifications which you can get in a...
What is Race around Condition?
What is a Development Plan ?
What is a Co-operative Bank?
What are the properties of Laser?
Top 5 Websites for Academic Research
What is regula-falsi method?
Top 10 Engineering YouTube Channels for Engineers
What is Lorentz Transformation?
What are Toposheets?
What is Pumping and its types?
Computers

What is Stacks?

by Bhumika 19/01/2022
written by Bhumika 19/01/2022 0 comment

A stack is a linear data structure that operates on the Last-In-First-Out (LIFO) principle. The Stacks has only one end, but the Queue has two (front and rear). It just has one pointer (top pointer) that points to the stack’s topmost element. When a new element is added to the stack, it is placed at the top, and the element can only be removed from the stack. To put it another way, a stack may be thought of as a container in which insertion and deletion can be done from the top of the stack.

In a linear data structure format, a stack represents a sequence of objects or elements. All operations are performed on the top position of the stack, which has a bounded bottom. The top value is incremented by one whenever an element is added to the stack by the push operation, and it is decremented by one whenever an element is pulled out of the stack by the pop operation. The stack pointer is a pointer that points to the top of the stack.

Operation of Stacks

The following are some  operations – 

PUSH operation

The following are the steps involved in the PUSH operation:

  • We verify whether a stack is full before adding an element to it.
  • The overflow problem happens when we try to insert the element into a stack that is already full.
  • We set the value of top to -1 when we create a stack to ensure that it is empty.
  • When a new element is pushed into a stack, the value of the top is first incremented, i.e. top=top+1, and then the element is moved to the new top position.
  • The items will be placed till the stack reaches its maximum size.

POP operation

The following are the steps involved in the POP operation:

  • We check whether the stack is empty before deleting the element from it.
  • When we try to remove an element from an empty stack, we get an underflow condition.
  • If the stack isn’t empty, we start with the element pointed to by the top.
  • The top is decremented by one after the pop operation, i.e. top=top-1.

Fig 1 – Push  n pop Operation Example

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

  • What is data structure?
  • Explain Sorting Algorithm?
  • What is Recursion?
  • Illustrate Cloud Computing?
Share
0
FacebookTwitterPinterestLinkedinTumblr
previous post
CBSE Class 12 Term 1 English Core Paper Answer Key 2021 Released
next post
What is the PLI scheme?

You may also like

What is the difference between Overloading and Overriding?

05/05/2022

What is the Line Drawing Algorithm in computer...

05/05/2022

What is the purpose of the Database System?

05/05/2022

What is the difference between Html and Html5?

25/04/2022

What is the Abstract data type in Data...

25/04/2022

What are the Characteristics of an Algorithm?

25/04/2022

What is Java Virtual Machine?

25/04/2022

What are the Advantages of LAN?

25/04/2022

What is the difference between system software and...

25/04/2022

What are the Benefits and Drawbacks of Ring...

20/04/2022

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

Keep in touch

Facebook Twitter Instagram Youtube

Popular Posts

  • 1

    What is Race around Condition?

    03/08/2021
  • 2

    What is a Development Plan ?

    02/08/2021
  • 3

    What is a Co-operative Bank?

    03/08/2021
  • 4

    What are the properties of Laser?

    02/07/2021
  • 5

    Top 5 Websites for Academic Research

    11/07/2021
  • 6

    What is regula-falsi method?

    03/08/2021
  • 7

    Top 10 Engineering YouTube Channels for Engineers

    10/07/2021
  • 8

    What is Lorentz Transformation?

    02/07/2021
  • 9

    What are Toposheets?

    07/07/2021
  • 10

    What is Pumping and its types?

    03/08/2021

Categories

  • Arts
  • Career
  • Chemistry
  • Civil
  • Commerce
  • Computers
  • E-Learning
  • Electronics
  • Engineering
  • Exams
  • Hiring News
  • Maths
  • Physics
  • Scholarships
  • Uncategorized

Read alsox

What is a Computer?

06/05/2021

What is DNS or Domain name...

31/05/2021

What are Pointers?

28/09/2021