• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data structure in real world

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you study Data structure, You read about stack, Queue and tree.

In real world, Which project did you build that use Queue? or stack?May you give me example for them?
 
Stephan van Hulst
Bartender
Pie
Posts: 6114
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All sorts. For example, stacks are very important in memory management. Queues are useful for job dispatching. If you have several threads they can take jobs out of a queue while new jobs are put in the queue from the other end.
Trees are used a lot in sorting, recursion, etc.

They are fundamental data structures, and are useful in various applications.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are entire products designed to do nothing but manage queues. For example, I work in healthcare. We have a central repository that holds medical data from (literally) hundreds of different applications distributed among 15 hospitals and scores of provider locations.

Imagine a scenario without queues. Each application would have to have a dedicated listener. Since most applications don't send 24/7, many of those listeners would be idle a LOT of the time, wasting CPU time and memory. Or, you could have a few listeners that are constantly hopping around, checking first this one, then that one, then the next. Each time a new interface is added or subtracted, you'd have to re-write your list of what to check. Meanwhile, a bunch of applications are blocked from sending while they wait their turn. If you have real-time data (think vital signs during an operation), do you really want that stuck, being held up, while a 200 page discharge report is being generated by some other application?

That sounds horrible.

Instead, we use queue management software. Every application connects to the queue manager, and can drop off new messages as fast as they want. Messages go into a queue. From there, they can be re-routed to other priority queues - so vitals and labs can be put on a 'process now' queue, and discharge reports can be put on a 'process when we have downtime' queue. We then have various worker processes that read from specific queues, and process the data as fast as they can.

It doesn't matter if an application has 1 or 10,000 documents to drop - they drop them as fast as they can on their queues. and the workers process off as fast as they can. No sender has to wait for a worker to be ready to process things.

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does undo redo use stack structure?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you'd typically use a stack for that. A stack is a last in, first out list.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic