![]() While inserting element in the stack we make the head pointer point to that element that we are inserting where as, in queue we make the rear pointer points to that element that we are inserting.In stack we define only one pointer "head" pointing to the top element of the stack, where as in Queue we define two pointers "front" and "rear" pointing to the first and last element of the queue respectively.The main difference in the dynamic implementation of stack vs queue are: Linked List Implementation of Queue: import java.util.* Linked List Implementation of Stack: import java.io.* Here I am going to implement stack and Queue using Linked list as it is the most efficient way to implement stack as well as queue. Both stack and queue can be implemented by using Array and Linked list.Both of them are flexible in size and can grow according to requirement of input. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |