Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

real-life applications of stack [closed]

Tags:

stack

I was trying to think of some non-CS related applications of the stack concept in the real life, unlike function calling, parsing, DFS, etc. but couldn't come up with any. For queues, I can think of several, e.g. assembly line in a factory, customer servicing in banks etc. but am not able to think of similar ones that work only via pushes & pops in the non-CS part of our daily life. Can someone please suggest somethings?

like image 321
vrk001 Avatar asked Feb 20 '23 16:02

vrk001


2 Answers

Your job.

When reducing staff, many companies are bound by agreements and regulations to use the "Last In First Out" to decide who goes and who stays.

The accountants like this because shorter service equates to lower redundancy payments. The unions or other staff representatives like this because it removes any possibility of favoritism and prejudice or victimization from the choices.

like image 119
James Anderson Avatar answered May 11 '23 22:05

James Anderson


There is one real-life example that even uses the FIFO and LIFO terminology: accounting.

Whenever a company buys supplies, it counts those supplies as expenses not when it buys them, but when it uses them. For instance, a company may buy a thousand pencils today, but use them over a year, and for financial reporting purposes it can report that over a year.

But what if the company buys pencils today and a month from today, and the price has changed in the meantime? For financial reporting purposes, the company has to pick a price for the pencils as it uses them. A year from now, as it uses the last of the thousand pencils, it could use the price for today's pencils, or it could use the price for next month's pencils.

Accounting standards don't give the company leeway to make up prices, so the costs have to come from real supplies (and you can't use one month's price to expense both shipments of supplies), but in the US at least there is some leeway for the ordering of the supplies for accounting purposes. Under FIFO, the pencils are assumed to be on a queue: the oldest pencil is expensed first. Under LIFO, the pencils are assumed to be on a stack: the newest pencil is expensed first.

like image 25
Adam Mihalcin Avatar answered May 11 '23 23:05

Adam Mihalcin