The collection of plates placed one over the other is a real-world example of a stack, whereas people standing in a queue to pay an electricity bill is a real-world example of the queue.Stacks are seen as a vertical linear collection, whereas queue can be seen as a horizontal linear collection of elements.The stack data structure can be used to solve problems like reversing a string, whereas the queue can be used to implement a blocking queue that ensures thread safety.The stack can be used to solve problems like pre-order, post-order and in-order traversal of the binary tree, which are based on recursion, whereas queue can be used to solve problems like producer-consumer problem involving sequential processing of underlying data.The stack data structure is a recursive data structure and is used in solving problems based on recursion, whereas queue is a sequential data structure and is used to solve problems involving sequential processing.In the stack’s case, only one pointer is maintained, whereas, in the queue, we require two pointers.Delete operation is stack is called pop whereas delete operation in the queue is called dequeue.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |