The stack is a list-like structure in which elements may be inserted or removed from only one end. While this restriction makes stacks less flexible than lists, it also makes stacks both efficient (for those operations they can do) and easy to implement. Many applications require only the limited form of insert and remove operations that stacks provi...

Read More

In this post we have alreday seen a Array based stack implementation.   As with the array-based Stack implementation, the Array must be declared of fixed size when the stack is created. In the stack constructor, size serves to indicate this size. Method top acts somewhat like a current position value (because the “current” position is always at the ...

Read More

 In a Stack, keep track of the max­i­mum element value in it. It might be the top ele­ment in the stack but once it the current max is poped out from the stack then the max­i­mum value should be the second maximum element in the stack. Algorithm: We will maintain 2 Stacks to solve the problem. The first one main stack will contains the elements and...

Read More

The stack is a list-like structure in which elements may be inserted or removed from only one end. While this restriction makes stacks less flexible than lists, it also makes stacks both efficient (for those operations they can do) and easy to implement. Many applications require only the limited form of insert and remove operations that stacks provi...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself