The enqueue operation is used to insert an element in the queue while the dequeue operation removes the element from the queue. Where as, Queue also performs mainly two operation enqueue and dequeue. The push operation is used to add an element in the stack and the pop operation is used to remove the element from the stack. Stack mainly performs two operations push and pop. The end from where insertion happens is known as rear amd the other end from where deletion occurs is known as front. Stack is open from one end only from which both insertion and deletion happens which is also known as top. Where as, Queue follows FIFO (First in First Out) principle in which the element which has been inserted at first will be removed first. Stack follows LIFO (Last in First Out) principle in which the element which has been inserted at last will be removed first. size() : It returns the size of the queue.getRear() : It returns the rear element of the queue from where insertion happens.getFront() : It returns the front element of the queue from where deletion happens.dequeue() : It is used to remove an item from the queue and return it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |