5 real life examples where stack operations are being used:- 1) Processing of procedure call and their termination. 2) Clothes in the tank 3) CD's in case 4) Rice packets in godown 5) Cars in garage
1) The real life examples of stacks are:
a. Bangles in a hand
b. Same circumference circular rings in a pole
c. Sacks full of wheat placed one over other:
d. Battery cells in a torch.
e. 1. Recursion
2.To convert decimal number to binary
3.Waiter serving orders one after another
4.Truck loaded with wooden boxes
5.To convert infix expression to post-fix
Design an algorithm to show the different operations on a stack?
zoology
Stack implementations allow us to easily implement backtracking algorithms.
A stack is a LIFO (last-in, first-out) data structure such that only the top-most element is accessible and all new elements are pushed onto the top (analogous to a stack of plates). Stacks are advantageous when implementing a back-tracking algorithm but are ultimately useless for anything else. However, this is not a disadvantage. If you're not implementing a back-tracking algorithm then the problem is not the stack itself it is the fact that you are using the wrong type of container for your algorithm.
// stack to contain content Stack sourceStack = new Stack(); // ... fill sourceStack with content // stack to contain reversed content Stack targetStack = new Stack(); while (!sourceStack.empty()) { targetStack.push(sourceStack.pop()); } // targetStack contains the reversed content of sourceStack
there are two operations you can do with a STACK one is PUSH operation and the other is POP operation
It is not possible to write a code to POP from the stack when there is no your stack implementation information.Because of that I am going to talk more about Stack in computer architecture and there will be additional link to specific examples(-e).In x86 architecture there is three registers (BP, SP and SS) which are connected with stack and only SP and SS is needed.SS - Stack Segment (base register);SP - Stack Pointer (offset);This is how the POP instruction works:# operand = [SS:SP] (top of the stack) # SP = SP + 2; (change SP to point to new top element)
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.
Stock sorting algorithm is a algorithm which is used to sort any kind of stock i.e. any data type containing the primitive values like array ,link list ,stack etc.
Stock sorting algorithm is a algorithm which is used to sort any kind of stock i.e. any data type containing the primitive values like array ,link list ,stack etc.
Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.
All major queue operations (push, pop and front) are constant time operations.