Implementing Genric queue data structure in Java
Given the linked list implementation of a generic queue in Java.
Rotten Oranges Problem
Given a Matrix of order M*N, where each cell can have zero or one orange. The orange in the cell (if present) can be either fresh or rotten. A rotten orange will rot the fresh oranges in the nearby cell in unit time. If a rotten orange is in cell (i,j), then it will rot […]
Implement Stack using two Queues
We have seen the code to implement a Queue using two stacks. This question is opposite of that. Use only Queue data structure to implement a Stack.
Implementing a Queue using two Stacks
We have seen how to implement Queue using a linked list and using Array as the base data structure. The question here is that given two Stacks, say S1 and S2, and no other data structure, simulate the functionality of a Queue, hence use two stacks as the base data structure for a Queue. i.e […]
Array implementation of Queue data structure
To learn the basics of the Queue visit our previous post on implementing Queue using linked list. In case the Queue is implemented using Linked list Enqueue (insertion) is about inserting a new node at the end and Dequeue (removing an element) is about deleting the first node. But, for array, things are little different.
Singly linked list implementation of Queue
In a general Queue (at any office or bank or any other place), people join the queue at the end and are removed from the front of queue. Similarly Queue data structure is a linear list of elements where element is always inserted at the end and deleted from the front.