Author: Sarah B Version: 1.0.0 (increment the patch/fix version number up if you make more commits past your first submission)
-
implement a Stack Class using,internally, a Linked List class
-
push(value) - BigO Space = 1 BigO Time = 1
-
pop() - BigO Space = 1 BigO Time = depending on implimentation as much as the length of the storage property
-
peek() - BigO Space = 1 BigO Time = 1
-
isEmpty() - BigO Space = 1 BigO Time = 1
This is a Stack 'class', basically a Stack object with these methods on its storage property:
- .pop
- .push
- .peek
- and .isEmpty
to use it first instantiate a new instance of the stack class either in the stack.js file or a new file where you have required in the stack.js module and storing it in the variable 'Stack'. Then: const newStack = new Stack(); and call the methods on its storage property: newStack.storage.push(value); will add a new value to the the storage property newStack.storage.pop will remove that same value from the storage property. if push is called multiple times, pop will remove the most recently pushed value: LIFO (Last In First Out) peek will return a copy of the value in the last node and isEmpty will return a boolean, true if the storage property is empty and false if it is not.
To run tests: type 'npm run testjest' in the CLI
- dependancies include npm
- To use this file, fork the repo, then npm i to install the necessary dependancies
4-30-18 -- Stack class is still buggy, PUSH, ISEMPTY and PEEK are more or less working, but POP is still in development