21BCA1946 Worksheet1.6
21BCA1946 Worksheet1.6
21BCA1946 Worksheet1.6
2. Task to be done: Creating a queue using the linked list and performing operations like
enqueue and dequeue on it.
class Node
{
public:
int data;
Node* next;
};
cur_head = 0;
cur_tail = 0;
Node* list[size];
for (int i = 0; i < size; i++)
{
list[i] = new Node();
}
for (int i = 0; i < size; i++)
{
list[i]->data = NULL;
list[i]->next = list[i+1];
if (i == size-1)
{
list[i]->next = NULL;
}
}
int ops;
while (loop == 1)
{
cout << "Select desired operation\n1. For Enqueue operation\n2. For Dequeue operation\n3.
To exit\n";
cin >> ops;
switch (ops)
{
case 1:
int val;
cout << "Enter the value to be inserted: ";
cin >> val;
enqueue(list[cur_tail], val);
break;
case 2:
dequeue(list[cur_head]);
break;
case 3:
loop = 0;
break;
default:
break;
}
}
return 0;
}
5. Result/Output/Writing Summary:
Evaluation Grid:
Worksheet Rubrics:
Understanding of Experiment 10% of total grade that is 2 marks
Command Description for all concepts covered in experiment 30% of total grade that is 6marks