Tutorial by Examples

The queue is a FIFO (first-in, first-out) data-structure, i.e. the first element added to the queue will be the first element removed ("first out"). Let us consider the example of customers waiting to be helped. Alice, Bob, and Dan are all at the supermarket. Alice is ready to pay, so she...
Queue follow FIFO as it is mentioned in the introduction. Five major operations: Enqueue(x): pushes x to the back of the queue. Dequeue(): pops an element from the front of the queue. isEmpty(): Finds whether the queue is empty or not. isFull(): Finds whether the queue is full or not. frontV...
Memory is efficiently organized in a circular queue as compared to linear queue. In Linear Queue: In Circular Queue: Remaining spaces can be used: Code for it to do the same: #include<stdio.h> #define MAX 10000 int front = -1; int rear = -1; int a[MAX]; bool isFull() { if...
Linked list representation is more efficient in terms of memory managerment. Code to show enqueue and deque in a Queue using Linklist in O(1) time. #include<stdio.h> #include<malloc.h> struct node{ int data; node* next; }; node* front = NULL; node* rear = NULL; vo...

Page 1 of 1