Stack and Queue Data structures

 

Queue and stack

 

Stack






Store the data as a real world stack we called this structure as the stack data structure.

Stack is what store something  one another something.

If we get a real world example collection of CDs are good example. Those are store in one on another. In there If we want to add another CD we have to add it to last CD’s up  and In other side if we want to remove CD from that CD collection in that case  also we do as remove from last added one to inside.



So the Concept of the Queue is the FIRST IN -LAST OUT or in other way we can tell it as LAST IN -FIRST OUT.


In PUSH operation we should have to give the value to the parameter, but POP is not require any value because POP removes the upper value of the stack indeedly.

Those processes are shows bellow,


Some key points related to stack

  • It behaves like a real-world stack, piles of books, etc.
  • A Stack store the limited data only.
  • Follow some structure to insert or to delete the data. 

 

Queue




Queue in data structure is real world queue and it behave as the way exactly queue behave in.

If we get real world queue in there first person in the queue is the one who finish his or her work at the first place. The last person is in the list fulfil his or her task at the point all  others finish there task.

So the concept of the Queue is FIRST IN-FIRST OUT or in other way we can tell it as LAST IN-LAST OUT.

 

Queue is Interface in JAVA. In that case we cannot create object for the for that as the way same to the QUEUE also so we cannot create object for the Queue also. But through the LinkList class implementation we can make that possible.


Queue process how is go on shows bellow,


There are type of queues in data structure

1.      Simple Queue

2.      Circular Queue

3.      Priority Queue

4.      Double Ended Queue

 

 

Comments

Popular posts from this blog

Linked List Data Structures

Java OOPC -Encapsulation

Java OOPC - Interface