loading words...

Feb 05, 2019 19:19:49

FT3 Stack and Queue

by @hiro | 323 words | 23🔥 | 256💌

Hiro

Current day streak: 23🔥
Total posts: 256💌
Total words: 70380 (281 pages 📄)

This is 3rd post for Feynman Technique  (described in my post "Feynman Technique"). Today I will write about "Stack and Queue", which is one of the topics that is asked for coding question I wrote here. Let me try to explain "Stack and Queue" as plain as possible. 


Stack

"Stack" comes from "a stack of paper," which is piled up on the desk. 

  • If we need to put a new paper on this stack, it sits on the top of the stack. 
  • If we need to take the paper from this stack, the last paper that is set on the top of the stack is taken.

For example, there is a stack of paper with numbers "A", "B", "C", "D", "E". "A" is set on the bottom and "E" is on the top. If we add paper "X" and "Y", the stack look like "ABCDEXY" where "A" is the bottom and "Y" is on the top of the stack. If we need to take 3 paper from this stack, we take "Y", "X", "E" in this order. 


Queue

"Queue" comes from "a queue of people," where people are waiting for boba tea. 

  • If we need to add one person on the queue, he/she will line up at the end of the queue.
  • If we need to remove one person from the queue, he/she should be the first person who wait for the longest hours among the waiting people. 

For example, there is a queue of people "John", "Mary", "Tom", "Jane" in Boba shop. "John" is the first person to come there and "Jane" is the last person to be in a line. If other two person "Carie" and "Jason" come to this shop, the queue will be "John", "Mary", "Tom", "Jane", "Carie", "Jason." Then if one person is called, "John" is the person who goes to get the next boba.


- Hiro


--- Grammarly counter: 0





  


contact: email - twitter / Terms / Privacy