This content originally appeared on DEV Community and was authored by Code_Regina
-Intro to Stack
-BIG O of Stacks
-Intro to Queues
Intro to Stacks
A stack is a last in first out data structure (LIFO) which means that the last element added to the stack will be the first element removed from the stack.
Stacks are used to manage function invocations.
As well as undo/redo actions.
BIG O of Stacks
Intro to Queues
A queue is a first in first out data structure (FIFO)
queues are used in background tasks, uploading resources, printing / task processing
class Queue {
constructor() {
this.first = null;
this.last = null;
this.size = 0;
}
}
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
This content originally appeared on DEV Community and was authored by Code_Regina

Code_Regina | Sciencx (2021-10-01T23:57:46+00:00) Stacks and Queues. Retrieved from https://www.scien.cx/2021/10/01/stacks-and-queues/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.