際際滷

際際滷Share a Scribd company logo
DATA STRUCTURE
D AY 3
BY : M O H A M M E D E L S D O D Y
QUEUE
 Like Stack, Queue is a linear structure which follows a particular order in which the
operations are performed. The order is First In First Out (FIFO)
QUEUE
 A good example of queue is any queue of consumers for a resource where the
consumer that came first is served first.
STACKS AND QUEUES
 Stack follows LIFO( last in first out) i.e element inserted first will come out at the end
while Queue follows FIFO(first in first out) i.e element inserted first will come out first.
STACKS AND QUEUES
 Stack A stack is a linear data structure in which elements can be inserted and deleted only from one
side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element
inserted at the last is the first element to come out. The insertion of an element into stack is
called push operation, and deletion of an element from the stack is called pop operation. In stack we
always keep track of the last element present in the list with a pointer called top.
Queue: A queue is a linear data structure in which elements can be inserted only from one side of
the list called rear, and the elements can be deleted only from the other side called the front. The
queue data structure follows the FIFO (First In First Out) principle, i.e. the element inserted at first in
the list, is the first element to be removed from the list. The insertion of an element in a queue is
an enqueue operation and the deletion of an element is called a dequeue operation. In queue we
always maintain two pointers, one pointing to the element which was inserted at the first and still
present in the list with the front pointer and the second pointer pointing to the element inserted at
the last with the rear pointer.

More Related Content

Data structure day4

  • 1. DATA STRUCTURE D AY 3 BY : M O H A M M E D E L S D O D Y
  • 2. QUEUE Like Stack, Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO)
  • 3. QUEUE A good example of queue is any queue of consumers for a resource where the consumer that came first is served first.
  • 4. STACKS AND QUEUES Stack follows LIFO( last in first out) i.e element inserted first will come out at the end while Queue follows FIFO(first in first out) i.e element inserted first will come out first.
  • 5. STACKS AND QUEUES Stack A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into stack is called push operation, and deletion of an element from the stack is called pop operation. In stack we always keep track of the last element present in the list with a pointer called top. Queue: A queue is a linear data structure in which elements can be inserted only from one side of the list called rear, and the elements can be deleted only from the other side called the front. The queue data structure follows the FIFO (First In First Out) principle, i.e. the element inserted at first in the list, is the first element to be removed from the list. The insertion of an element in a queue is an enqueue operation and the deletion of an element is called a dequeue operation. In queue we always maintain two pointers, one pointing to the element which was inserted at the first and still present in the list with the front pointer and the second pointer pointing to the element inserted at the last with the rear pointer.