Implement a stack using javascript

Problem description :

Create a stack data structure in javascript.

  • Stack organizes data into the sequential order. It similar to the stack of books in a library or stack of dishes in the kitchen as shown below.


Logic :

  • It is similar to linked list. Linked list has a head attribute whereas Stack has top attribute.

  • Linked list is usually visualized horizontally from (left to right ) whereas Stack is visualized vertically (from bottom to top).

  • Stack data structure supports two basic operations : push and pop as shown below.


Solution :

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *