You are on page 1of 9

Topic: Queue Worksheet No.

Work sheet No. 6

QUEUE – Array implementation

Name: ____________________ Reg.No.: ______________________ Date: ____________

1. What are the major operations of queue data structures

2. What is the difference between a Stack and a Queue?


Stack Queue

3. Let q be a queue. What is the output of the following:


q.enqueue(15); cout<<q.dequeue(); Cout<<“Empty? “
q.enqueue(20); cout<<q.peek(); <<q.isEmpty();
q.enqueue(13); q.dequeue(); q.dequeue();
q.enqueue(39); q.dequeue(); int num = q.dequeue() +
q.enqueue(4); q.enqueue (12); q.dequeue();
q.enqueue(11); cout<< num;

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No. 6

4. List some applications of Queue

5. A queue data structure uses ____________________ principle with the help of


variables '___________' and '_______________'.

6. Whenever, we want to insert a new value into the queue, increment '___________'
value by one and then insert at that position. Whenever we want to delete a value
from the queue, then increment ________________ value by one.

7. Queue is said to be full if _________________________

8. Queue is said to be empty if _________________________

9. While initializing the stack,


queue()
{
rear=___________;
front=___________;
}
10. void enqueue(int x)
{ if(_________________)
{
cout <<"queue over flow";
front=rear=-1;
return;
}
queue1[______________]=x;
cout <<"inserted" <<x;
}
11. void dequeue()
{ if(_________________)
{
cout <<"queue under flow";
return;
}
cout <<"deleted" <<queue1[____________];
}

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No. 6

12. Word Search

1. LINKEDLIST
2. LINEAR
3. FRONT
4. STACK
5. PEEK
6. ARRAY
7. DEQUEUE
8. QUEUE
9. ENQUEUE
10. REAR

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No.7

Work sheet No. 7

QUEUE – Linked List implementation

Name: ____________________ Reg.No.: _____________________ Date: ____________

1. The major problem with the queue implemented using array is


___________________________________________________________________________.

2. Queue using linked list can work for _____________________ size of data.

3. In linked list implementation of a queue, the last inserted node is always pointed by
________________ and the first node is always pointed by ______________________.

4. Insert the elements 10,15,22,50 in the following queue structure

a? b? c? d? e?

Front Rear
5. Dequeue(), dequeue(), enqueue(10), enqueue(15). Show the output.

a? b? c? d? e?

Front Rear
6. Fill up the blanks
void queue::insert()
{ if(frnt==NULL)
int value; ___________________________;
struct node *ptr; else
cout<<"\nInsertion\n"; rear->next=_____________;
cout<<"Enter a number to insert:"; ________________;
cin>>value; cout<<"\nNew item is inserted to the
ptr=new node; Queue!!!";
___________________=value; }
ptr->next=____________;

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No.7

7. void queue::del()

{ struct node *temp;

if(__________________) temp=frnt;

{ frnt=______________;

cout<<"\nQueue is empty!!"; cout<<"\n Deleted value is "<<___________;

return; delete temp;

} }

8. Solve the following Crossword puzzle

Across
3. To remove an element into the
queue
5. Deletion
7. Returns first value without
dequeue
8. Rear==size-1
Down
1. To insert an element into the
queue
2. Insertion
4. Front = Rear =-1
5. Principle of Queue
6. RearNext

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No. 8

Work sheet No. 8

Circular Queue

Name: ____________________ Reg.No.: _____________________ Date: ____________

1. Circular queue is a ______________ data structure. It follows _____________ principle.


2. Circular queue is also called as “____________________”.
3. Write the condition whether queue is FULL. ___________________________________
4. Write the condition whether queue is EMPTY. ___________________________________
5. void insert(int data)
{
node *p=new node;
p->data=data;
if(rear==NULL)
{
rear=p;
rear->next=p;
}
else
{
p->next=_____________;
rear->next=_________;
________________;
}
}
6. void del()
{
if(_________________)
cout<<"Queue Empty";
else
{
node *t=rear->next;
cout<<"The element to be deleted is"<<rear->next->data;
if(rear==t)
rear=____________;
else
{
rear->next=____________;
delete t;
}
}
}

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No. 9

Work sheet No. 9

Applications of QUEUE – Priority queue – Double ended queue

Name: ____________________ Reg.No.: _____________________ Date: ____________

1. List the applications of Queue

2. List the properties of Priority Queue

3. List the operations supported by priority queue

4. Complete the code

void insert(int item, int priority)


{
node *tmp, *q;
tmp = new node;
tmp->info = item;
tmp->priority = priority;
if (front == NULL || priority < front->priority)
{
_____________________;
front = tmp;
}

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No. 9

else
{
q = front;
while (q->link != NULL && q->link->priority <= priority)
q=q->link;
tmp->link =_____________;
q->link = tmp;
}
}

5. List the Applications of Priority Queue:

6. Double ended Queue is also called as ___________________


7. Define Double ended queue.

8. Double Ended Queue can be represented in TWO ways, those are

___________________________________.

___________________________________.

9. Name the structure ________________________________


Delete
Insert

Delete
Front Rear

10. Name the structure _______________________________

Insert Insert

Delete

Front Rear

Mrs. Selva Mary. G 15CS201J- Data Structures


Topic: Queue Worksheet No. 9

11. Solve the following Crossword

Across Down
5. Queue that removes element based on the 1. In input restricted double ended queue, the
certain values is called __________ queue ________ operation is performed at only one
end
6. Double ended Queue is also called as
___________ 2. (front == -1 && rear == -1) Queue is ____

7. In output restricted double ended queue, 3. remove minimum element first from queue
the __________ operation is performed at
only one end 4. rear == SIZE-1 && front == 0) || (front ==
rear+1)) Queue is ____
8. Elements are inserted in the order in which
they arrive the queue and always higher
value is removed first from the queue

Mrs. Selva Mary. G 15CS201J- Data Structures

You might also like