Monday, December 26, 2022

Queue Implementation using Stacks

 








Circular Queue in java using arrays

 










Introduction & Implementation of Queue using Linked-List

                           

            

                                                  Queue { FIFO - First In First Out}

Enqueue: It is an add operation in java   for arrays it takes 0(1) and in linked list it takes 0(1) time

Dequeue: It is remove operation in java   for arrays it takes 0(n) and in linked list it takes 0(1) time

Peek: It is an peek operation in java  for arrays it takes 0(1) and in linked list it takes 0(1) time


Implementation using Linked List: 

Here the elements are added from the back that is rear and removed from the front 









Queue Implementation using Stacks