Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //Constructor function for Node
  2. const Node = function (data) {
  3. this.data = data;
  4. this.next=null;
  5. }
  6. //Constructor function for Stack
  7. const Stack = function (){
  8. this.top=null;
  9. this.size= 0;
  10. this.min=null;
  11. }
  12. //Just add to prototype and all the objects inherit that behavior
  13. Stack.prototype.push = function (data){
  14. //..
  15.  
  16. }
  17. Stack.prototype.pop = function (){
  18. //..
  19. }
  20. Stack.prototype.peek = function (){
  21. //..
  22. }
  23. Stack.prototype.isEmpty = function () {return this.top===null;}
  24. Stack.prototype.minimum = function () {return this.min}
  25.  
  26. let a = new Stack()
  27. a.push(1)
  28. a.push(-1)
  29. a.push(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement