answersLogoWhite

0


Best Answer

Consider an array used as a stack. Align this array vertically. When an element is inserted into the stack, it is pushed all the way down despite the space availability at the top. Hence it is called push operation. Here's an illustration:

Stack initially:


|_|

|_|

|_|

|5|


Stack after the insertion of 6:


|_|

|_|

|6| - element pushed down as much as possible

|5|

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why insert operation in stack called as push operation?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is push operation in data structure?

Push inserts a value onto the top of the stack. Pop extracts the top value from the stack. These are the two primary operations that can be performed upon a stack. Prior to popping a value, you will first check the stack is not empty, store the top value, then pop the stack. For a stack of type T, you might use the following: if (!stack.empty()) { T value {stack.top()}; // copy top value stack.pop(); // remove value from stack // use value... }


Define stack.discuss push and pop operation?

A stack is a region of memory that you store things, and retrieve them in the reverse order of storage. Think of it as a stack of papers. You write something down on a piece of paper, and then you put that paper in a stack, specifically on the top of the stack. This is called a push operation. If you want to go and do something else, such as service an interrupt or call another function, you create more pieces of paper and you push them onto the top of the stack as well. Under normal conditions, you cannot access anything on the stack below the top. I say "normal" because the architecture of the processor allows you to access chunks of memory contained within the stack, relative to the base pointer BP, allowing you to pass arguments and store temporary variables in what is called a stack frame. The reverse of push is called pop, and it is equivalent to taking a piece of paper off of the top of the stack and throwing it away - or using it, whatever you want - but that action exposes the next piece of paper, which is now the new "top of stack".


Implement a class stack which simulates the operations of the stack allowing LIFO operationsAlso implement push and pop operations for the stack?

/* C program to implement stack. Stack is a LIFO data strcuture LIFO - Last in First Out Perform PUSH(insert operation), POP(Delete operation) and Display stack */#include #include #define MAXSIZE 5struct stack /* Structure definition for stack */{int stk[MAXSIZE];int top;};typedef struct stack STACK;STACK s;/* Function declaration/Prototype*/void push (void);int pop(void);void display (void);void main (){int choice;int option = 1;clrscr ();s.top = -1;printf ("STACK OPERATION\n");while (option){printf ("--------------\n");printf (" 1 -> PUSH \n");printf (" 2 -> POP \n");printf (" 3 -> DISPLAY \n");printf (" 4 -> EXIT \n");printf ("--------------\n");printf ("Enter your choice\n");scanf ("%d", &choice);switch (choice){case 1: push();break;case 2: pop();break;case 3: display();break;case 4: return;}fflush (stdin);printf ("Do you want to continue(Type 0 or 1)?\n");scanf ("%d", &option);}}/*Function to add an element to the stack*/void push (){int num;if (s.top -1){printf ("Stack is empty\n");return;}else{printf ("\nThe status of the stack is\n");for (i = s.top; i >= 0; i-){printf ("%d\n", s.stk[i]);}}printf ("\n");}byankit shukla


What is time complexity of stack?

All major queue operations (push, pop and front) are constant time operations.


Define list of operation on stack?

There are 4 main widely used stack operations.Operations:* POP - increase stack pointer and return top element * PUSH - putting element into stack's top * TOP - returns data of top element on stack * LENGTH/SIZE - returns number of elements inside stack For more detailed implementation details, please check web links.

Related questions

What are the stack operation?

there are two operations you can do with a STACK one is PUSH operation and the other is POP operation


What is push operation in data structure?

Push inserts a value onto the top of the stack. Pop extracts the top value from the stack. These are the two primary operations that can be performed upon a stack. Prior to popping a value, you will first check the stack is not empty, store the top value, then pop the stack. For a stack of type T, you might use the following: if (!stack.empty()) { T value {stack.top()}; // copy top value stack.pop(); // remove value from stack // use value... }


What is stack operation in 8085 microprocessor?

STACK operation in 8085 microprocessor.The stack is a reserved area of the memory in RAM where temporary information may be stored. An 8-bit stack pointer is used to hold the address of the most recent stack entry. This location which has the most recent entry is called as the top of the stack.When the information is written on the stack, the operation is called PUSH. When the information is read from the stack, the operation is called POP. The stack works on the principle of Last in First Out or Fist in Lat Out


What is stack in 8085 microprocessor?

STACK operation in 8085 microprocessor.The stack is a reserved area of the memory in RAM where temporary information may be stored. An 8-bit stack pointer is used to hold the address of the most recent stack entry. This location which has the most recent entry is called as the top of the stack.When the information is written on the stack, the operation is called PUSH. When the information is read from the stack, the operation is called POP. The stack works on the principle of Last in First Out or Fist in Lat Out


Define stack.discuss push and pop operation?

A stack is a region of memory that you store things, and retrieve them in the reverse order of storage. Think of it as a stack of papers. You write something down on a piece of paper, and then you put that paper in a stack, specifically on the top of the stack. This is called a push operation. If you want to go and do something else, such as service an interrupt or call another function, you create more pieces of paper and you push them onto the top of the stack as well. Under normal conditions, you cannot access anything on the stack below the top. I say "normal" because the architecture of the processor allows you to access chunks of memory contained within the stack, relative to the base pointer BP, allowing you to pass arguments and store temporary variables in what is called a stack frame. The reverse of push is called pop, and it is equivalent to taking a piece of paper off of the top of the stack and throwing it away - or using it, whatever you want - but that action exposes the next piece of paper, which is now the new "top of stack".


What are the two methods to tell when the stack is full?

1. Operation 'push' returns with a STACK_FULL error code 2. Operation 'is_full' returns with TRUE


What is a stack and how do you represent a stack in computer memory also discuss basic operation performed on a stack?

A stack is an abstraction of First-in-last-out, or the last in first out. The basic operations (may bear different names) Push or Add Pop or Next


What is the function of the stack counter?

Its not a stack counter - its a stack pointer. The stack pointer is a register that points to the top of the stack. In the Intel configuration, it points to the next item to be popped off the stack. To push an item requires that the stack pointer be decremented first, and then the item is written. The inverse operation - the pop - requires read then increment.


Implement a class stack which simulates the operations of the stack allowing LIFO operationsAlso implement push and pop operations for the stack?

/* C program to implement stack. Stack is a LIFO data strcuture LIFO - Last in First Out Perform PUSH(insert operation), POP(Delete operation) and Display stack */#include #include #define MAXSIZE 5struct stack /* Structure definition for stack */{int stk[MAXSIZE];int top;};typedef struct stack STACK;STACK s;/* Function declaration/Prototype*/void push (void);int pop(void);void display (void);void main (){int choice;int option = 1;clrscr ();s.top = -1;printf ("STACK OPERATION\n");while (option){printf ("--------------\n");printf (" 1 -> PUSH \n");printf (" 2 -> POP \n");printf (" 3 -> DISPLAY \n");printf (" 4 -> EXIT \n");printf ("--------------\n");printf ("Enter your choice\n");scanf ("%d", &choice);switch (choice){case 1: push();break;case 2: pop();break;case 3: display();break;case 4: return;}fflush (stdin);printf ("Do you want to continue(Type 0 or 1)?\n");scanf ("%d", &option);}}/*Function to add an element to the stack*/void push (){int num;if (s.top -1){printf ("Stack is empty\n");return;}else{printf ("\nThe status of the stack is\n");for (i = s.top; i >= 0; i-){printf ("%d\n", s.stk[i]);}}printf ("\n");}byankit shukla


What is time complexity of stack?

All major queue operations (push, pop and front) are constant time operations.


How do you use push operation in stack give the exampale of the program?

A stack can be implemented as an array or a list. If an array, simply push the new element onto the end of the array. If a list, point the new node at the head node then make the new node the new head of the list.


How stack pointer registers are involved in the execution of push and pop instruction?

If the stack is empty assume the stack pointer has a value of P. when you push something on the stack you increment P. when you pull something from stack you decrement P.