Skip to content

Commit

Permalink
Update article.md
Browse files Browse the repository at this point in the history
Based on the comments, we changed the example and simplified the content
  • Loading branch information
dujue55 authored Oct 30, 2024
1 parent 9c050bb commit 04fbef3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions 2024/stack-queue/article.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!-- BEGIN TITLE -->
## What Supermarkets Can Teach Us About Data Structure?
# What Supermarkets Can Teach Us About Data Structure?
<!-- END TITLE -->




<!-- BEGIN BODY -->
Imagine in a supermarket. When restocking, The employee usually places new items at the front of the existing ones. Customers typically take items from the outermost position. In this way, the most recently added products are the first to be purchased. In computer science, this is called **'stacks'** , following the "Last In, First Out" (LIFO) principle.
Imagine in a supermarket, Customers line up to pay, with the first to join being served first. New arrivals join the end of the line, ensuring an orderly process. In computer science, this is called **'queues'**, following the 'First In, First Out' (FIFO) rule.

Customers waiting to pay for their groceries form a line, where the first customer to join is the first to be served. After completing their payment, the next one in line moves forward. New customers always join the back of the line, ensuring that the checkout process is orderly. In computer science, this is called **'queues'**, following the 'First In, First Out' (FIFO) principle.
After shopping, customers generally place their baskets in a pile at the entrance. In general, the next customer takes the top basket, meaning the last one placed is taken first. In computer science, this is called **'stacks'**, following the 'Last In, First Out' (LIFO) rule.

Programmers do this as well, queues and stacks are simple yet powerful tools in the their toolkit. They help organize data efficiently, ensuring that tasks are handled either in the order they arrive (queues) or in reverse order of their addition (stacks).
Programmers use stacks and queues to organize data efficiently. Queues handle tasks in arrival order, while stacks process tasks in reverse order of their addition.
<!-- END BODY -->
<img src="./illustration.png" style="width: 50%;">


## Author
<!-- BEGIN AUTHOR -->
Expand Down

0 comments on commit 04fbef3

Please sign in to comment.