DEV Community

Code_Regina
Code_Regina

Posted on • Updated on

Stacks and Queues

                   -Intro to Stack
                   -BIG O of Stacks
                   -Intro to Queues
Enter fullscreen mode Exit fullscreen mode

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

Alt Text

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; 
  }
 }


Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I don't really see how the #css and #html tags fit on this post