MODULE II
1. Write a c program to perform insertion, deletion and display operation on queue(10)
(OR) Define queue. Write Qinsert and Qdelete procedures for queues using arrays(10)
2. Write short note on dequeue and priority queue(5)
3. Write a function CQinsert() and CQdelete() operation on circular queue(8)
4. What is linked list. List and explain the different types of linked list with examples(8)
5. Write a c function for the following operations on linked list(12)
a. Insertion at the beginning
b. Insertion at the end
c. Deletion at the beginning
d. Deletion at the end
(OR) Write the following algorithms for singly linked list:
e. Inserting ITEM as the first node in the list
f. Deleting the last node in the list
6. Define Ackerman function recursively and evaluate A(3,0). Also, develop c code for the
same (7)
7. Differentiate single(SLL) and Doubly(DLL) linked list(4)
8. Write the function for: i) finding the length of the list ii) concatenation two list iii)
Reverse the list (10)
9. Write a c function for the following operations on Circular linked list(12)
a. Insertion at the beginning
b. Insertion at the end
c. Deletion at the beginning
d. Deletion at the end
(OR) Write a c function to insert a node at front and delete a node from the rear end in a
circularly linked list(8)
10. What is recursion? Write the recursive procedure for
a. Finding GCD of two numbers
b. To find n fibonacci number
c. Factorial of a number
11. Write and explain how do you implement the operations of stack using singly linked
list(SLL) with the help of C-statement(10)
12. Write a node structure for the linked representation of a polynomial. Explain the
algorithm to add two polynomials represented using linked list(8)
13. Write a C function to add two polynomials represented as circular list with header
node(8)
,1. Write a c program to perform insertion, deletion and display operation on queue(10)
(OR)Define queue. Write Qinsert and Qdelete procedures for queues using arrays(10)
C Program
#include<conio.h>
#include<stdio.h>
#include<process.h>
#define MAX 50
int queue_arr[MAX];
int rear = –1;
int front = –1;
void insert ()
{
int added_item;
if (rear==MAX-1)
{
printf("\nQueue Overflow\n");
getch();
return;
}
else
{
if (front==–1)
front=0;
printf(“\nInput the element for adding in queue: ”);
scanf(“%d”, &added_item);
rear=rear+1;
queue_arr[rear] = added_item ;
}
}
void del()
{
if (front == –1 || front > rear)
{
printf ("\nQueue Underflow\n");
return;
}
else
{
printf ("\nElement deleted from queue is : %d\n",queue_arr[front]);
front=front+1;
}
}
void display()
{
int i;
, if (front == –1 || front > rear)
{
printf (“\nQueue is empty\n”);
return;
}
else
{
printf(“\nQueue is :\n”);
for(i=front;i<= rear;i++)
printf(“%d ”,queue_arr[i]);
printf(“\n”);
}
}
void main()
{
int choice;
while (1)
{
clrscr();
printf(“\n1.Insert\n”);
printf(“2.Delete\n”);
printf(“3.Display\n”);
printf(“4.Quit\n”);
printf(“\nEnter your choice:”);
scanf(“%d”, & choice);
switch(choice)
{
case 1 :
insert(); break;
case 2:
del();
getch(); break;
case 3:
display();
getch(); break;
case 4:
exit(1);
default:
printf (“\n Wrong choice\n”);
getch();
}
}
}
2. Write short note on dequeue and priority queue(5)
1. Write a c program to perform insertion, deletion and display operation on queue(10)
(OR) Define queue. Write Qinsert and Qdelete procedures for queues using arrays(10)
2. Write short note on dequeue and priority queue(5)
3. Write a function CQinsert() and CQdelete() operation on circular queue(8)
4. What is linked list. List and explain the different types of linked list with examples(8)
5. Write a c function for the following operations on linked list(12)
a. Insertion at the beginning
b. Insertion at the end
c. Deletion at the beginning
d. Deletion at the end
(OR) Write the following algorithms for singly linked list:
e. Inserting ITEM as the first node in the list
f. Deleting the last node in the list
6. Define Ackerman function recursively and evaluate A(3,0). Also, develop c code for the
same (7)
7. Differentiate single(SLL) and Doubly(DLL) linked list(4)
8. Write the function for: i) finding the length of the list ii) concatenation two list iii)
Reverse the list (10)
9. Write a c function for the following operations on Circular linked list(12)
a. Insertion at the beginning
b. Insertion at the end
c. Deletion at the beginning
d. Deletion at the end
(OR) Write a c function to insert a node at front and delete a node from the rear end in a
circularly linked list(8)
10. What is recursion? Write the recursive procedure for
a. Finding GCD of two numbers
b. To find n fibonacci number
c. Factorial of a number
11. Write and explain how do you implement the operations of stack using singly linked
list(SLL) with the help of C-statement(10)
12. Write a node structure for the linked representation of a polynomial. Explain the
algorithm to add two polynomials represented using linked list(8)
13. Write a C function to add two polynomials represented as circular list with header
node(8)
,1. Write a c program to perform insertion, deletion and display operation on queue(10)
(OR)Define queue. Write Qinsert and Qdelete procedures for queues using arrays(10)
C Program
#include<conio.h>
#include<stdio.h>
#include<process.h>
#define MAX 50
int queue_arr[MAX];
int rear = –1;
int front = –1;
void insert ()
{
int added_item;
if (rear==MAX-1)
{
printf("\nQueue Overflow\n");
getch();
return;
}
else
{
if (front==–1)
front=0;
printf(“\nInput the element for adding in queue: ”);
scanf(“%d”, &added_item);
rear=rear+1;
queue_arr[rear] = added_item ;
}
}
void del()
{
if (front == –1 || front > rear)
{
printf ("\nQueue Underflow\n");
return;
}
else
{
printf ("\nElement deleted from queue is : %d\n",queue_arr[front]);
front=front+1;
}
}
void display()
{
int i;
, if (front == –1 || front > rear)
{
printf (“\nQueue is empty\n”);
return;
}
else
{
printf(“\nQueue is :\n”);
for(i=front;i<= rear;i++)
printf(“%d ”,queue_arr[i]);
printf(“\n”);
}
}
void main()
{
int choice;
while (1)
{
clrscr();
printf(“\n1.Insert\n”);
printf(“2.Delete\n”);
printf(“3.Display\n”);
printf(“4.Quit\n”);
printf(“\nEnter your choice:”);
scanf(“%d”, & choice);
switch(choice)
{
case 1 :
insert(); break;
case 2:
del();
getch(); break;
case 3:
display();
getch(); break;
case 4:
exit(1);
default:
printf (“\n Wrong choice\n”);
getch();
}
}
}
2. Write short note on dequeue and priority queue(5)