Stack = LIFO = DFS
Stack is LIFO
(Last In First Out
).
// Add to the BACK of the array: .append() // py .push() // js // Removes from the BACK of the array: .pop() // js & py
Stack allows for backtracking which allows implementation of depth first search.
Queue = FIFO = BFS
Queue is FIFO
(First in First out
)
// Add to the BACK of the array .append() // py .push() // js // Remove from the FRONT of the array .shift() // js .remove() OR .pop(0) // py