fave77 / Mathball

A JavaScript library for Competitive Programming
https://fave77.github.io/Mathball-Docs/
MIT License
99 stars 49 forks source link

Add stacks data structure #89

Closed Shubhayu-Das closed 5 years ago

Shubhayu-Das commented 5 years ago

Do the checklist before filing the issue:

NOTE: Provide a clear and concise description of the feature that needs to be added! Or if its a bug, then provide the necessary steps to reproduce it along with screenshots.

Stacks are often very useful in competitive programming owing to their LIFO property. Add a data structure with the following function:

Push(data) - Insert data into the stack.

Pop() - Delete the topmost element from the stack.

Top() - Return the topmost element(HEAD) of the stack without popping it.

copy() - Returns a copy passed stack object. Example: Stack1 = [ 3, 2, 1]; let Stack2 = copy(Stack1); //Stack2 also stores [3, 2, 1] now

isEmpty() - returns true if the stack has no elements in it. Returns false otherwise.

printStack() - prints all the elements of the stack. (In LIFO Order only.)

Refer to: https://www.geeksforgeeks.org/implementation-stack-javascript/

fave77 commented 5 years ago

@sateslayer will you be working on this?

Shubhayu-Das commented 5 years ago

Yes I will work on it.

fave77 commented 5 years ago

@sateslayer Implement it like PriorityQueue