Job Shadow with Will Meier at Agency Zero in Denver
January 5, 2018
Pros and Cons of ReactJS
January 8, 2018
 

Describe stacks & queues

 

Monday, January 8th, 2018

Stacks & Queues — Data Structure and Algorithm

Stacks and Queues are similar in structure but vary in use. These type of data structures help organize data in a particular order like arrays and lists. An example of where to use this would be adding objects on a temporary list and use the same objects for later on.

The difference between the two is with the removal of data. Stacks are Last In First Out (LIFO), while queues are First In First Out (FIFO).

Stacks — LIFO

Stacks: a data structure based on LIFO – last in, first out. The newest file is at the top of the stack to be used next in line. A stacks two primary operations are called push and pop – where push places a new item at the top of the stack and a pop retrieves the topmost element from the stack. Stacks can be access from beginning and end, but not the middle.

Queues — FIFO

Queues: a line that utilizes “FIFO” organization. Enqueue places a new element at a queue’s “tail” end, while dequeue retrieves an element at a queues head. Queues, like stacks, can be accessed from the ends, but not the middle.