answersLogoWhite

0

This is not possible as this violates the basic definition of stack...That can have only two primitive operations "Push" "POP"

If u want to implement what u want u can do that by some implementation of Push pop combination but that is what other data strutures like queue do....

User Avatar

Wiki User

12y ago

What else can I help you with?

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 time complexity of stack?

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


What are some common operations that can be performed on a stack data structure?

Common operations that can be performed on a stack data structure include push (adding an element to the top of the stack), pop (removing the top element from the stack), peek (viewing the top element without removing it), and isEmpty (checking if the stack is empty).


What is Push and pops?

Push and pop relate to sequence containers where elements can be inserted and removed from the sequence with push and pop operations, respectively. Typically, push and pop apply to one end of the sequence, but not necessarily at the same end. However, if a push or a pop can be applied to both ends of a sequence, the operations are named push_front, push_back, pop_front and pop_back. Ideally, push and pop are constant-time operations. However, depending on the container type, a push or pop at one end may be more efficient than at the other. The following is a summary of common container types and the efficiencies that can be expected: A vector supports push and pop at either end. However, push_back and pop_back are constant time operations unless a reallocation occurs (we can reserve memory at the end of the vector to minimise the need for reallocations) whereas push_front and pop_front are always linear-time operations. A forward list supports push and pop at the head of the list only, both of which are constant-time operations. A bi-directional list supports push and pop at either end, all of which are constant-time operations. A queue supports push at the back and pop at the front, both of which are constant-time operations. A deque (double-ended-queue) supports push and pop at either end, all of which are constant-time operations. A stack supports push and pop at the top of the stack, both of which are constant time operations. Note that a fixed-length array does not support push or pop operations because it cannot grow or shrink in size.


What is interface stack?

The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with five operations that allow a vector to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty, and a method to search the stack for an item and discover how far it is from the top.


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 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 it called when forces push on both sides of an object?

Compression.


What does pop stand for in internet slang?

In computing, PUSH and POP refer to the principal operations with a stack data structure, where pushadds a new item on the top of the stack and pop removes an item from the top of the stack.


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.


What is a queue Explain various operations perfomed using stack with examples?

Stack has the following operations:1) push - insert an element into the stack2) pop - remove an element out of the stack3) top - display the topmost element in the stackQueue has the following operations:1) enqueue - insert an element into the queue2) dequeue - remove an element from the queue3) front - display the element at the front of the queue(next element to be dequeued)4) rear - display the element at the rear of the queue(last element enqueued)The following operations can be performed in both stack and queue:1) size - returns the size of the container2) isempty - returns whether the container is empty or not


Can stack be as a pointer?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Stack pointer is the pointer that points to the top of the stack or that points the item at the top of the stack and help in adding or deleting the item from the top of stack.