VND - Openxmlformats Officedocument - Wordprocessingml.document&rendition 1
VND - Openxmlformats Officedocument - Wordprocessingml.document&rendition 1
Output
Enter the number of days in the week: 7 Enter
details for Day 1:
Enter the day name: Sunday
Enter the date: 1
Enter the activity for the day: Learning Enter
details for Day 2:
Enter the day name: Monday
Enter the date: 2
Enter the activity for the day: Coding Enter details
for Day 3:
Enter the day name: Tuesday
Enter the date: 3
Enter the activity for the day: Testing Enter details
for Day 4:
Enter the day name: Wednesday
Enter the date: 4
Enter the activity for the day: Debugging Enter
details for Day 5:
Enter the day name: Thrusday
Enter the date: 5
Enter the activity for the day: Publishing Enter
details for Day 6:
Enter the day name: Friday
Enter the date: 6
Enter the activity for the day: Marketing Enter
details for Day 7:
Enter the day name: Saturday
Enter the date: 7
Enter the activity for the day: Earning Week's
Activity Details:
Day 1:
Day Name: Sunday
Date: 1
Activity: Learning Day 2:
Day Name: Monday
Date: 2
Activity: Coding Day 3:
Day Name: Tuesday
Date: 3
Activity: Testing Day 4:
Day Name: Wednesday
Date: 4
Activity: Debugging Day 5:
Day Name: Thrusday
Date: 5
Activity: Publishing Day 6:
Day Name: Friday
Date: 6
Activity: Marketing Day 7:
Day Name: Saturday
Date: 7
Activity: Earning
2) Develop a Program in C for the following
operations on Strings.
a. Read a main String (STR), a Pattern String (PAT)
and a Replace String (REP)
b. Perform Pattern Matching Operation: Find and
Replace all occurrences of PAT in
STR with REP if PAT exists in STR. Report suitable
messages in case PAT does not
exist in STR
Support the program with functions for each of
the above operations. Don't use Built-in
functions.
#include<stdio.h> char str[50], pat[20], rep[20],
res[50];
int c = 0, m = 0, i = 0, j = 0, k, flag = 0;
void stringmatch() {
while (str[c] != '\0') {
if (str[m] == pat[i]) {
i++;
m++;
if (pat[i] == '\0') {
flag = 1;
for (k = 0; rep[k] != '\0'; k++, j++) {
res[j] = rep[k];
}
i = 0;
c = m;
}
} else {
res[j] = str[c];
j++;
c++;
m = c;
i = 0;
}
}
res[j] = '\0';
}
void main() {
printf("Enter the main string:");
gets(str);
printf("\nEnter the pat string:");
gets(pat);
printf("\nEnter the replace string:");
gets(rep);
printf("\nThe string before pattern match is:\n
%s", str);
stringmatch();
if (flag == 1)
printf("\nThe string after pattern match and
replace is: \n %s ", res);
else
printf("\nPattern string is not found");
}
O/P
Enter the main string:Designed by vtucode Enter
the pat string:vtucode Enter the replace
string:Braham The string before pattern match is:
Designed by vtucode
The string after pattern match and replace is:
Designed by Braham
Enter the main string:Designed by Developer
Enter the pat string:vtucode Enter the replace
string:Braham The string before pattern match is:
Designed by Developer
Pattern string is not found
O/P
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 11
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 12
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 13
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 14
~~~~Stack overflow~~~~ ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 4
Stack elements are:
| 13 |
| 12 |
| 11 | ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 2
Element popped is: 13 ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 4
Stack elements are:
| 12 |
| 11 | ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 2
Element popped is: 12 ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 2
Element popped is: 11 ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 2
~~~~Stack underflow~~~~ ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 4
~~~~Stack is empty~~~~ ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 11
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 22
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 11
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 3
Stack content are:
| 11 |
| 22 |
| 11 | Reverse of stack content are:
| 11 |
| 22 |
| 11 | It is palindrome number
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 2
Element popped is: 11 ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 2
Element popped is: 22 ~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 33
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 1
Enter an element to be pushed: 22
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 3
Stack content are:
| 22 |
| 33 |
| 11 | Reverse of stack content are:
| 11 |
| 33 |
| 22 | It is not a palindrome number
~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow
demo
=>3.Palindrome demo
=>4.Display
=>5.Exit Enter your choice: 5
4) Develop a Program in C for converting an Infix
Expression to Postfix Expression. Program
should support for both parenthesized and free
parenthesized
expressions with the operators: +, -, *, /, %
(Remainder), ^ (Power) and alphanumeric
operands.
#include<stdio.h> #include<stdlib.h> void
evaluate();
void push(char);
char pop();
int prec(char); char infix[30], postfix[30],
stack[30];
int top = -1; void main() {
printf("\nEnter the valid infix expression:");
scanf("%s", infix);
evaluate();
printf("\nThe entered infix expression is :\n %s \
n", infix);
printf("\nThe corresponding postfix expression
is :\n %s \n", postfix);
} void evaluate() {
int i = 0, j = 0;
char symb, temp; push('#'); for (i = 0; infix[i] != '\
0'; i++) {
symb = infix[i];
switch (symb) {
case '(':
push(symb);
break; case ')':
temp = pop();
while (temp != '(') {
postfix[j] = temp;
j++;
temp = pop();
}
break;
case '+':
case '-':
case '*':
case '/':
case '%':
case '^':
case '$':
while (prec(stack[top]) >= prec(symb)) {
temp = pop();
postfix[j] = temp;
j++;
}
push(symb);
break;
default:
postfix[j] = symb;
j++;
}
}
while (top > 0) {
temp = pop();
postfix[j] = temp;
j++;
}
postfix[j] = '\0';
} void push(char item) {
top = top + 1;
stack[top] = item;
} char pop() {
char item;
item = stack[top];
top = top - 1;
return item;
} int prec(char symb) {
int p;
switch (symb) {
case '#':
p = -1;
break; case '(':
case ')':
p = 0;
break; case '+':
case '-':
p = 1;
break; case '*':
case '/':
case '%':
p = 2;
break; case '^':
case '$':
p = 3;
break;
}
return p;
}
O/P
Enter the valid infix expression:(a+b)*c/d^5%1
The entered infix expression is :
(a+b)*c/d^5%1 The corresponding postfix
expression is :
ab+c*d5^/1%
O/P
Enter the number of discs: 3 Move disc 1 from A
to C
Move disc 2 from A to B
Move disc 1 from C to B
Move disc 3 from A to C
Move disc 1 from B to A
Move disc 2 from B to C
Move disc 1 from A to C Total Number of moves
are: 7
6) Develop a menu driven Program in C for the
following operations on Circular QUEUE of
Characters (Array Implementation of Queue with
maximum size MAX)
a. Insert an Element on to Circular QUEUE
b. Delete an Element from Circular QUEUE
c. Demonstrate Overflow and Underflow
situations on Circular QUEUE
d. Display the status of Circular QUEUE
e. Exit
Support the program with appropriate functions
for each of the above operations
#include <stdio.h> #include<stdlib.h>
#include<stdio_ext.h> #define MAX 3 char
cq[MAX];
int front = -1, rear = -1; void insert(char);
void delete();
void display();
void main() {
int ch;
char item;
while (1) {
printf("\n\n~~Main Menu~~");
printf("\n==> 1. Insertion and Overflow Demo");
printf("\n==> 2. Deletion and Underflow Demo");
printf("\n==> 3. Display");
printf("\n==> 4. Exit");
printf("\nEnter Your Choice: ");
scanf("%d", & ch);
__fpurge(stdin);
switch (ch) {
case 1:
printf("\n\nEnter the element to be inserted: ");
scanf("%c", & item);
insert(item);
break;
case 2:
delete();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("\n\nPlease enter a valid choice");
}
}
} void insert(char item) {
if (front == (rear + 1) % MAX) {
printf("\n\n~~Circular Queue Overflow~~");
} else {
if (front == -1)
front = rear = 0;
else
rear = (rear + 1) % MAX;
cq[rear] = item;
}
} void delete() {
char item;
if (front == -1) {
printf("\n\n~~Circular Queue Underflow~~");
} else {
item = cq[front];
printf("\n\nDeleted element from the queue is:
%c ", item); if (front == rear) //only one element
front = rear = -1;
else
front = (front + 1) % MAX;
}
} void display() {
int i;
if (front == -1) {
printf("\n\nCircular Queue Empty");
} else {
printf("\nCircular Queue contents are:\n");
printf("Front[%d]-> ", front);
for (i = front; i != rear; i = (i + 1) % MAX) {
printf(" %c", cq[i]);
}
printf(" %c", cq[i]);
printf(" <-[%d]Rear", rear);
}
}
O/P
~~Main Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 1
Enter the element to be inserted: A ~~Main
Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 1
Enter the element to be inserted: B ~~Main
Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 1
Enter the element to be inserted: C ~~Main
Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 1
Enter the element to be inserted: D
~~Circular Queue Overflow~~ ~~Main Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 3
Circular Queue contents are:
Front[0]-> A B C <-[2]Rear ~~Main Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 2
Deleted element from the queue is: A ~~Main
Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 3
Circular Queue contents are:
Front[1]-> B C <-[2]Rear ~~Main Menu~~
==> 1. Insertion and Overflow Demo
==> 2. Deletion and Underflow Demo
==> 3. Display
==> 4. Exit Enter Your Choice: 4
7) Develop a menu driven Program in C for the
following operations on Singly Linked List
(SLL) of Student Data with the fields: USN, Name,
Programme, Sem,
PhNo
a. Create a SLL of N Students Data by using front
insertion.
b. Display the status of SLL and count the number
of nodes in it
c. Perform Insertion / Deletion at End of SLL
d. Perform Insertion / Deletion at Front of
SLL(Demonstration of stack)
e. Exit
~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:1 Enter the no of
students: 3
Enter the usn,Name,Branch, sem,PhoneNo of the
student:
1ME21CS017
Braham
CSE
5
8768586443 Enter the usn,Name,Branch,
sem,PhoneNo of the student:
1ME21CS015
Bikash
CSE
5
8734687996 Enter the usn,Name,Branch,
sem,PhoneNo of the student:
1ME21AI015
Shoaib
AI&ML
5
6748353877 ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:2
The contents of SLL: ||1|| USN:1ME21AI015|
Name:Shoaib| Branch:AI&ML| Sem:5|
Ph:6748353877|
||2|| USN:1ME21CS015| Name:Bikash|
Branch:CSE| Sem:5| Ph:8734687996|
||3|| USN:1ME21CS017| Name:Braham|
Branch:CSE| Sem:5| Ph:8768586443|
No of student nodes is 3 ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:3 Enter the
usn,Name,Branch, sem,PhoneNo of the student:
1ME21CS068
Rajan
CSE
5
3426527765 ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:2
The contents of SLL: ||1|| USN:1ME21AI015|
Name:Shoaib| Branch:AI&ML| Sem:5|
Ph:6748353877|
||2|| USN:1ME21CS015| Name:Bikash|
Branch:CSE| Sem:5| Ph:8734687996|
||3|| USN:1ME21CS017| Name:Braham|
Branch:CSE| Sem:5| Ph:8768586443|
||4|| USN:1ME21CS068| Name:Rajan|
Branch:CSE| Sem:5| Ph:3426527765|
No of student nodes is 4 ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:4
The student node with the usn:1ME21CS068 is
deleted ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:2
The contents of SLL: ||1|| USN:1ME21AI015|
Name:Shoaib| Branch:AI&ML| Sem:5|
Ph:6748353877|
||2|| USN:1ME21CS015| Name:Bikash|
Branch:CSE| Sem:5| Ph:8734687996|
||3|| USN:1ME21CS017| Name:Braham|
Branch:CSE| Sem:5| Ph:8768586443|
No of student nodes is 3 ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:4
The student node with the usn:1ME21CS017 is
deleted ~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:5
~~~Stack Demo using SLL~~~ 1:Push operation
2: Pop operation
3: Display
4:Exit Enter your choice for stack demo:1 Enter
the usn,Name,Branch, sem,PhoneNo of the
student:
1ME21CS005
Aman
CSE
5
6587594335 ~~~Stack Demo using SLL~~~ 1:Push
operation
2: Pop operation
3: Display
4:Exit Enter your choice for stack demo:3
The contents of SLL: ||1|| USN:1ME21CS005|
Name:Aman| Branch:CSE| Sem:5|
Ph:6587594335|
||2|| USN:1ME21AI015| Name:Shoaib|
Branch:AI&ML| Sem:5| Ph:6748353877|
||3|| USN:1ME21CS015| Name:Bikash|
Branch:CSE| Sem:5| Ph:8734687996|
No of student nodes is 3 ~~~Stack Demo using
SLL~~~ 1: Push operation
2: Pop operation
3: Display
4: Exit Enter your choice for stack demo:1 Enter
the usn,Name,Branch, sem,PhoneNo of the
student:
1ME21CS092
Shubham
CSE
5
9869754354 ~~~Stack Demo using SLL~~~
1:Push operation
2: Pop operation
3: Display
4:Exit Enter your choice for stack demo:3
The contents of SLL: ||1|| USN:1ME21CS092|
Name:Shubham| Branch:CSE| Sem:5|
Ph:9869754354|
||2|| USN:1ME21CS005| Name:Aman|
Branch:CSE| Sem:5| Ph:6587594335|
||3|| USN:1ME21AI015| Name:Shoaib|
Branch:AI&ML| Sem:5| Ph:6748353877|
||4|| USN:1ME21CS015| Name:Bikash|
Branch:CSE| Sem:5| Ph:8734687996|
No of student nodes is 4 ~~~Stack Demo using
SLL~~~ 1:Push operation
2: Pop operation
3: Display
4:Exit Enter your choice for stack demo:2
The Student node with usn:1ME21CS092 is
deleted ~~~Stack Demo using SLL~~~ 1:Push
operation
2: Pop operation
3: Display
4:Exit Enter your choice for stack demo:3
The contents of SLL: ||1|| USN:1ME21CS005|
Name:Aman| Branch:CSE| Sem:5|
Ph:6587594335|
||2|| USN:1ME21AI015| Name:Shoaib|
Branch:AI&ML| Sem:5| Ph:6748353877|
||3|| USN:1ME21CS015| Name:Bikash|
Branch:CSE| Sem:5| Ph:8734687996|
No of student nodes is 3 ~~~Stack Demo using
SLL~~~ 1: Push operation
2: Pop operation
3: Display
4: Exit Enter your choice for stack demo:4
~~~Menu~~~
Enter your choice for SLL operation 1:Create SLL
of Student Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:Stack Demo using SLL(Insertion and Deletion at
Front)
6:Exit Enter your choice:6
8) Develop a menu driven Program in C for the
following operations on Doubly Linked List
(DLL) of Employee Data with the fields: SSN,
Name, Dept, Designation,
Sal, PhNo
a. Create a DLL of N Employees Data by using end
insertion.
b. Display the status of DLL and count the number
of nodes in it
c. Perform Insertion and Deletion at End of DLL
d. Perform Insertion and Deletion at Front of DLL
e. Demonstrate how this DLL can be used as
Double Ended Queue.
f. Exit
#include<stdio.h> #include<stdlib.h> struct node
{
char ssn[25], name[25], dept[10],
designation[25];
int sal;
long int phone;
struct node * llink;
struct node * rlink;
};
typedef struct node * NODE; NODE first = NULL;
int count = 0; NODE create() {
NODE enode;
enode = (NODE) malloc(sizeof(struct node));
if (enode == NULL) {
printf("\nRunning out of memory");
exit(0);
}
printf("\nEnter the
ssn,Name,Department,Designation,Salary,PhoneN
o of the employee: \n");
scanf("%s %s %s %s %d %ld", enode -> ssn, enode
-> name, enode -> dept, enode -> designation, &
enode -> sal, & enode -> phone);
enode -> llink = NULL;
enode -> rlink = NULL;
count++;
return enode;
} NODE insertfront() {
NODE temp;
temp = create();
if (first == NULL) {
return temp;
}
temp -> rlink = first;
first -> llink = temp;
return temp;
} void display() {
NODE cur;
int nodeno = 1;
cur = first;
if (cur == NULL)
printf("\nNo Contents to display in DLL");
while (cur != NULL) {
printf("\nENode:%d||SSN:%s|Name:%s|
Department:%s|Designation:%s|Salary:%d|Phone
no:%ld", nodeno, cur -> ssn, cur -> name, cur ->
dept, cur -> designation, cur -> sal, cur -> phone);
cur = cur -> rlink;
nodeno++;
}
printf("\nNo of employee nodes is %d", count);
} NODE deletefront() {
NODE temp;
if (first == NULL) {
printf("\nDoubly Linked List is empty");
return NULL;
}
if (first -> rlink == NULL) {
printf("\nThe employee node with the ssn:%s is
deleted", first -> ssn);
free(first);
count--;
return NULL;
}
temp = first;
first = first -> rlink;
temp -> rlink = NULL;
first -> llink = NULL;
printf("\nThe employee node with the ssn:%s is
deleted", temp -> ssn);
free(temp);
count--;
return first;
} NODE insertend() {
NODE cur, temp;
temp = create(); if (first == NULL) {
return temp;
}
cur = first;
while (cur -> rlink != NULL) {
cur = cur -> rlink;
} cur -> rlink = temp;
temp -> llink = cur;
return first;
} NODE deleteend() {
NODE prev, cur;
if (first == NULL) {
printf("\nDoubly Linked List is empty");
return NULL;
} if (first -> rlink == NULL) {
printf("\nThe employee node with the ssn:%s is
deleted", first -> ssn);
free(first);
count--;
return NULL;
} prev = NULL;
cur = first; while (cur -> rlink != NULL) {
prev = cur;
cur = cur -> rlink;
} cur -> llink = NULL;
printf("\nThe employee node with the ssn:%s is
deleted", cur -> ssn);
free(cur);
prev -> rlink = NULL;
count--;
return first;
} void deqdemo() {
int ch;
while (1) {
printf("\nDemo Double Ended Queue
Operation");
printf("\n1:InsertQueueFront\n 2:
DeleteQueueFront\n 3:InsertQueueRear\n
4:DeleteQueueRear\n 5:DisplayStatus\n 6: Exit \
n");
scanf("%d", & ch); switch (ch) {
case 1:
first = insertfront();
break;
case 2:
first = deletefront();
break;
case 3:
first = insertend();
break;
case 4:
first = deleteend();
break;
case 5:
display();
break;
default:
return;
}
}
} void main() {
int ch, i, n;
while (1) {
printf("\n\n~~~Menu~~~");
printf("\n1:Create DLL of Employee Nodes");
printf("\n2:DisplayStatus");
printf("\n3:InsertAtEnd");
printf("\n4:DeleteAtEnd");
printf("\n5:InsertAtFront");
printf("\n6:DeleteAtFront");
printf("\n7:Double Ended Queue Demo using
DLL");
printf("\n8:Exit \n");
printf("\nPlease enter your choice: ");
scanf("%d", & ch); switch (ch) {
case 1:
printf("\nEnter the no of Employees: ");
scanf("%d", & n);
for (i = 1; i <= n; i++)
first = insertend();
break; case 2:
display();
break; case 3:
first = insertend();
break; case 4:
first = deleteend();
break; case 5:
first = insertfront();
break; case 6:
first = deletefront();
break; case 7:
deqdemo();
break; case 8:
exit(0);
default:
printf("\nPlease Enter the valid choice");
}
}
}
O/P
~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 1
Enter the no of Employees: 2 Enter the
ssn,Name,Department,Designation,Salary,PhoneN
o of the employee:
1EPL
Braham
Developer
Senior
13627
8476283712 Enter the
ssn,Name,Department,Designation,Salary,PhoneN
o of the employee:
2EPL
Aman
Trader
Manager
20000
2763578156 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 2 ENode:1||SSN:1EPL|
Name:Braham|Department:Developer|
Designation:Senior|Salary:13627|Phone
no:8476283712
ENode:2||SSN:2EPL|Name:Aman|
Department:Trader|Designation:Manager|
Salary:20000|Phone no:2763578156
No of employee nodes is 2 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 3 Enter the
ssn,Name,Department,Designation,Salary,PhoneN
o of the employee:
3EPL
Bikash
Meeting
Manager
30000
8237462936 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 2 ENode:1||SSN:1EPL|
Name:Braham|Department:Developer|
Designation:Senior|Salary:13627|Phone
no:8476283712
ENode:2||SSN:2EPL|Name:Aman|
Department:Trader|Designation:Manager|
Salary:20000|Phone no:2763578156
ENode:3||SSN:3EPL|Name:Bikash|
Department:Meeting|Designation:Manager|
Salary:30000|Phone no:8237462936
No of employee nodes is 3 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 5 Enter the
ssn,Name,Department,Designation,Salary,PhoneN
o of the employee:
4EPL
Shoaib
Digital Marketing
Manager
40000
2835826437 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit Please enter your choice: 2 ENode:1||
SSN:4EPL|Name:Shoaib|Department:Digital
Marketing|Designation:Manager|Salary:40000|
Phone no:2835826437
ENode:2||SSN:1EPL|Name:Braham|
Department:Developer|Designation:Senior|
Salary:13627|Phone no:8476283712
ENode:3||SSN:2EPL|Name:Aman|
Department:Trader|Designation:Manager|
Salary:20000|Phone no:2763578156
ENode:4||SSN:3EPL|Name:Bikash|
Department:Meeting|Designation:Manager|
Salary:30000|Phone no:8237462936
No of employee nodes is 4 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 4 The employee node
with the ssn:3EPL is deleted ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 6 The employee node
with the ssn:4EPL is deleted ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 2 ENode:1||SSN:1EPL|
Name:Braham|Department:Developer|
Designation:Senior|Salary:13627|Phone
no:8476283712
ENode:2||SSN:2EPL|Name:Aman|
Department:Trader|Designation:Manager|
Salary:20000|Phone no:2763578156
No of employee nodes is 2 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit
Please enter your choice: 7 Demo Double Ended
Queue Operation
1:InsertQueueFront
2: DeleteQueueFront
3:InsertQueueRear
4:DeleteQueueRear
5:DisplayStatus
6: Exit
Please enter your choice: 2 The employee node
with the ssn:1EPL is deleted Demo Double Ended
Queue Operation
1:InsertQueueFront
2: DeleteQueueFront
3:InsertQueueRear
4:DeleteQueueRear
5:DisplayStatus
6: Exit
Please enter your choice: 4 The employee node
with the ssn:2EPL is deleted Demo Double Ended
Queue Operation
1:InsertQueueFront
2: DeleteQueueFront
3:InsertQueueRear
4:DeleteQueueRear
5:DisplayStatus
6: Exit
Please enter your choice: 2 Doubly Linked List is
empty Demo Double Ended Queue Operation
1:InsertQueueFront
2: DeleteQueueFront
3:InsertQueueRear
4:DeleteQueueRear
5:DisplayStatus
6: Exit
Please enter your choice: 6 ~~~Menu~~~
1:Create DLL of Employee Nodes
2:DisplayStatus
3:InsertAtEnd
4:DeleteAtEnd
5:InsertAtFront
6:DeleteAtFront
7:Double Ended Queue Demo using DLL
8:Exit Please enter your choice: 8
O/P
~~~Menu~~~
1.Represent and Evaluate a Polynomial P(x,y,z)
2.Find the sum of two polynomials POLY1(x,y,z)
and POLY2(x,y,z)
Enter your choice: 1 ~~~~Polynomial evaluation
P(x,y,z)~~~
Enter the no of terms in the polynomial: 5
Enter the 1 term:
Coef = 6
Enter Pow(x) Pow(y) and Pow(z): 2 2 1
Enter the 2 term:
Coef = -4
Enter Pow(x) Pow(y) and Pow(z): 0 1 5
Enter the 3 term:
Coef = 3
Enter Pow(x) Pow(y) and Pow(z): 3 1 1
Enter the 4 term:
Coef = 2
Enter Pow(x) Pow(y) and Pow(z): 1 5 1
Enter the 5 term:
Coef = -2
Enter Pow(x) Pow(y) and Pow(z): 1 1 3
Representation of Polynomial for evaluation:
6x^2y^2z^1 + -4x^0y^1z^5 + 3x^3y^1z^1 +
2x^1y^5z^1 + -2x^1y^1z^3
Enter the value of x,y and z: 1 1 1
Result of polynomial evaluation is : 5
~~~Menu~~~
1.Represent and Evaluate a Polynomial P(x,y,z)
2.Find the sum of two polynomials POLY1(x,y,z)
and POLY2(x,y,z)
Enter your choice: 2 Enter the POLY1(x,y,z):
Enter the no of terms in the polynomial: 5
Enter the 1 term:
Coef = 6
Enter Pow(x) Pow(y) and Pow(z): 4 4 4
Enter the 2 term:
Coef = 3
Enter Pow(x) Pow(y) and Pow(z): 4 3 1
Enter the 3 term:
Coef = 5
Enter Pow(x) Pow(y) and Pow(z): 0 1 1
Enter the 4 term:
Coef = 10
Enter Pow(x) Pow(y) and Pow(z): 0 1 0
Enter the 5 term:
Coef = 5
Enter Pow(x) Pow(y) and Pow(z): 0 0 0
Polynomial 1 is:
6x^4y^4z^4 + 3x^4y^3z^1 + 5x^0y^1z^1 +
10x^0y^1z^0 + 5x^0y^0z^0 Enter the
POLY2(x,y,z):
Enter the no of terms in the polynomial: 5
Enter the 1 term:
Coef = 8
Enter Pow(x) Pow(y) and Pow(z): 4 4 4
Enter the 2 term:
Coef = 4
Enter Pow(x) Pow(y) and Pow(z): 4 2 1
Enter the 3 term:
Coef = 30
Enter Pow(x) Pow(y) and Pow(z): 0 1 0
Enter the 4 term:
Coef = 20
Enter Pow(x) Pow(y) and Pow(z): 0 0 1
Enter the 5 term:
Coef = 3
Enter Pow(x) Pow(y) and Pow(z): 0 0 0
Polynomial 2 is:
8x^4y^4z^4 + 4x^4y^2z^1 + 30x^0y^1z^0 +
20x^0y^0z^1 + 3x^0y^0z^0 Polynomial addition
result:
14x^4y^4z^4 + 3x^4y^3z^1 + 4x^4y^2z^1 +
5x^0y^1z^1 + 40x^0y^1z^0 + 20x^0y^0z^1 +
8x^0y^0z^0 ~~~Menu~~~
1.Represent and Evaluate a Polynomial P(x,y,z)
2.Find the sum of two polynomials POLY1(x,y,z)
and POLY2(x,y,z)
Enter your choice:3
~~~~BST MENU~~~~
1.Create a BST
2.Search
3.BST Traversals:
4.Exit
Enter your choice: 1 Enter the number of
elements: 12
Enter The value: 6
Enter The value: 9
Enter The value: 5
Enter The value: 2
Enter The value: 8
Enter The value: 15
Enter The value: 24
Enter The value: 14
Enter The value: 7
Enter The value: 8
Enter The value: 5
Enter The value: 2 ~~~~BST MENU~~~~
1.Create a BST
2.Search
3.BST Traversals:
4.Exit
Enter your choice: 3 The Preorder display: 6
5 2 9 8 7 15 14 24
The Inorder display: 2 5 6 7
8 9 14 15 24
The Postorder display: 2 5 7 8
14 24 15 9 6 ~~~~BST MENU~~~~
1.Create a BST
2.Search
3.BST Traversals:
4.Exit
Enter your choice: 2 Enter Element to be
searched: 66
Key element is not found in the BST ~~~~BST
MENU~~~~
1.Create a BST
2.Search
3.BST Traversals:
4.Exit
Enter your choice: 2 Enter Element to be
searched: 14
Key element is present in BST ~~~~BST
MENU~~~~
1.Create a BST
2.Search
3.BST Traversals:
4.Exit
Enter your choice: 4
*************************case-
1************************* Enter the
number of vertices in graph:4
Enter the adjacency matrix:
0101
0010
0001
0000
Enter the starting vertex: 1
==>1. BFS: Print all nodes reachable from a given
starting node
==>2. DFS: Print all nodes reachable from a given
starting node
==>3:Exit
Enter your choice: 1
Nodes reachable from starting vertex 1 are: 2 4 3
*************************case-
2************************* Enter the
number of vertices in graph:4
Enter the adjacency matrix:
0101
0010
0001
0000
Enter the starting vertex: 2
==>1. BFS: Print all nodes reachable from a given
starting node
==>2. DFS: Print all nodes reachable from a given
starting node
==>3:Exit
Enter your choice: 1
Nodes reachable from starting vertex 2 are: 3 4
The vertex that is not reachable is 1
*************************case-
3************************* Enter the
number of vertices in graph:4
Enter the adjacency matrix:
0101
0010
0001
0000
Enter the starting vertex: 1
==>1. BFS: Print all nodes reachable from a given
starting node
==>2. DFS: Print all nodes reachable from a given
starting node
==>3:Exit
Enter your choice: 2
Nodes reachable from starting vertex 1 are: 2 3 4
*************************case-
4************************* Enter the
number of vertices in graph:4
Enter the adjacency matrix:
0101
0010
0001
0000
Enter the starting vertex: 2
==>1. BFS: Print all nodes reachable from a given
starting node
==>2. DFS: Print all nodes reachable from a given
starting node
==>3:Exit
Enter your choice: 2
Nodes reachable from starting vertex 2 are: 3 4
O/P