diff --git a/src/data-structures/stack/Stack.js b/src/data-structures/stack/Stack.js index 762b428e..dd007d2c 100644 --- a/src/data-structures/stack/Stack.js +++ b/src/data-structures/stack/Stack.js @@ -2,8 +2,8 @@ import LinkedList from '../linked-list/LinkedList'; export default class Stack { constructor() { - // We're going to implement Queue based on LinkedList since this - // structures a quite similar. Compare push/pop operations of the Stack + // We're going to implement Stack based on LinkedList since these + // structures are quite similar. Compare push/pop operations of the Stack // with append/deleteTail operations of LinkedList. this.linkedList = new LinkedList(); } @@ -12,7 +12,7 @@ export default class Stack { * @return {boolean} */ isEmpty() { - // The queue is empty in case if its linked list don't have tail. + // The stack is empty if its linked list doesn't have a tail. return !this.linkedList.tail; } @@ -21,7 +21,7 @@ export default class Stack { */ peek() { if (this.isEmpty()) { - // If linked list is empty then there is nothing to peek from. + // If the linked list is empty then there is nothing to peek from. return null; } @@ -34,7 +34,7 @@ export default class Stack { */ push(value) { // Pushing means to lay the value on top of the stack. Therefore let's just add - // new value at the end of the linked list. + // the new value at the end of the linked list. this.linkedList.append(value); } @@ -42,8 +42,8 @@ export default class Stack { * @return {*} */ pop() { - // Let's try to delete the last node from linked list (the tail). - // If there is no tail in linked list (it is empty) just return null. + // Let's try to delete the last node (the tail) from the linked list. + // If there is no tail (the linked list is empty) just return null. const removedTail = this.linkedList.deleteTail(); return removedTail ? removedTail.value : null; }