File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Data structure in  real world Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Data structure in  real world" Watch "Data structure in  real world" New topic

Data structure in real world

abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
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

Joined: Sep 20, 2010
Posts: 4635

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.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

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.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
Does undo redo use stack structure?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15094

Yes, you'd typically use a stack for that. A stack is a last in, first out list.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Data structure in real world
jQuery in Action, 3rd edition