Documente Academic
Documente Profesional
Documente Cultură
To spark the imagination of the Computer Science Engineers with values, skills and creativity to
solve the real world problems.
MISSION 1: To inculcate creative thinking and problem solving skills through effective teaching,
learning and research.
MISSION 2: To empower professionals with core competency in the field of Computer Science
and Engineering.
MISSION 3: To foster independent and life-long learning with ethical and social responsibilities.
PEO 1: To empower students with effective computational and problem solving skills.
PEO 2: To enable students with core skills for employment and entrepreneurship.
PEO 4: To foster students with research oriented ability which helps them in analyzing and solving
real life problems and motivate them for pursuing higher studies.
PROGRAMME OUTCOMES:
Engineering Graduates will be able to:
PO1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
PO3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
PO4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
PO5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
PO6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
PO7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
PO8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.
PO11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
PO12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change
PROGRAMME SPECIFIC OUTCOMES:
PSO 1: An ability to apply foundation of Computer Science and Engineering, algorithmic principles and
theory in designing and modelling computation based systems.
PSO 2: The ability to demonstrate software development skills.
Data Structure Lab (RCS-355)
COURSE OUTCOMES:
C209.1: Implement elementary data structures such as arrays and linked lists.
#include<stdio.h>
void create(int[],int);
void insertion_begin(int[]);
void insertion_loc(int[],int);
void deletion_loc(int[],int);
void search_ele(int[],int);
void display(int[]);
int n;
int main()
int arr[100],t=0;
scanf("%d",&n);
create(arr,n);
while(t==0)
printf("Enter 5 to exit\n");
int ch;
scanf("%d",&ch);
switch(ch)
case 1:
insertion_begin(arr);
break;
case 2:
int l;
scanf("%d",&l);
insertion_loc(arr,l-1);
break;
case 3:
scanf("%d",&l);
deletion_loc(arr,l-1);
break;
case 4:
int e;
scanf("%d",&e);
search_ele(arr,e);
break;
case 5:
t=1;
break;
default:
printf("wrong choice\n");
}
}
return 0;
int i,y;
for(i=0;i<n;i++)
scanf("%d",&y);
a[i]=y;
display(a);
int e,i;
scanf("%d",&e);
for(i=n-1;i>=0;i--)
a[i+1]=a[i];
a[0]=e;
n=n+1;
display(a);
{
int e,i;
scanf("%d",&e);
for(i=n-1;i>=l;i--)
a[i+1]=a[i];
a[l]=e;
n=n+1;
display(a);
int i;
for(i=l;i<n;i++)
a[i]=a[i+1];
n=n-1;
display(a);
int i;
for(i=0;i<n;i++)
printf("%d ",a[i]);
int i,t=0,l;
for(i=0;i<n;i++)
if(a[i]==e)
t=1;
l=i;
break;
if(t==1)
else
}
INPUT AND OUTPUT
Enter the size of the array
Enter 5 to exit
Enter 5 to exit
Enter 5 to exit
Enter 5 to exit
#include<stdio.h>
void input1();
void input2();
void add();
void multiply();
void transpose();
void display(int,int);
int i=4;
int a[50][50],b[50][50],ans[50][50];
int r1,r2,c1,c2;
void main()
int m,n;
for(m=0;m<r1;m++)
for(n=0;n<c1;n++)
ans[m][n]=0;
scanf("%d",&i);
while(i!=0)
switch(i)
case 2:
input2();
if(c1==r2)
multiply();
display(r1,c2);
Else
break;
case 1:
input2();
if((r1==r2)&&(c1==c2))
add();
display(r1,c1);
break;
case 3:
input1();
transpose();
display(c1,r1);
break;
default:
printf("WRONG CHOICE.INPUT AGAIN \n");
scanf("%d",&i);
void input2()
printf("ENTER THE SIZE OF BOTH THE ARRAYS MENTIONING ROWS AND COLUMNS RESPECTIVELY \n");
scanf("%d %d %d %d",&r1,&c1,&r2,&c2);
int m,n;
for(m=0;m<r1;m++)
for(n=0;n<c1;n++)
scanf("%d",&a[m][n]);
for(m=0;m<r2;m++)
for(n=0;n<c2;n++)
scanf("%d",&b[m][n]);
}
void input1()
printf("ENTER THE SIZE OF THE ARRAY MENTIONING ROWS AND COLUMNS RESPECTIVELY \n");
scanf("%d %d",&r1,&c1);
int m,n;
for(m=0;m<r1;m++)
for(n=0;n<c1;n++)
scanf("%d",&a[m][n]);
void add()
int m,n;
for(m=0;m<r1;m++)
for(n=0;n<c1;n++)
ans[m][n]+=a[m][n]+b[m][n];
void multiply()
int m,n,o;
for(m=0;m<r1;m++)
{
for(n=0;n<c2;n++)
for(o=0;o<r2;o++)
ans[m][n]+=a[m][o]*b[o][n];
void transpose()
int m,n;
for(m=0;m<c1;m++)
for(n=0;n<r1;n++)
ans[m][n]=a[m][n];
int m,n;
for(m=0;m<x;m++)
for(n=0;n<y;n++)
printf("%d ",ans[m][n]);
}
printf("\n");
}
INPUT AND OUTPUT
1)ARRAY ADDITION
2)ARRAY MULTIPILCATON
3)ARRAY TRANSPOSE
0)EXIT
ENTER THE SIZE OF BOTH THE ARRAYS MENTIONING ROWS AND COLUMNS RESPECTIVELY
24
68
1)ARRAY ADDITION
2)ARRAY MULTIPILCATON
3)ARRAY TRANSPOSE
0)EXIT
ENTER THE SIZE OF BOTH THE ARRAYS MENTIONING ROWS AND COLUMNS RESPECTIVELY
47 47 28 31
1)ARRAY ADDITION
2)ARRAY MULTIPILCATON
3)ARRAY TRANSPOSE
0)EXIT
ENTER THE SIZE OF THE ARRAY MENTIONING ROWS AND COLUMNS RESPECTIVELY
1)ARRAY ADDITION
2)ARRAY MULTIPILCATON
3)ARRAY TRANSPOSE
0)EXIT
CODE:
#include<stdio.h>
void bubble();
void insertion();
void selection();
int arr[50];
int n;
void main()
int c=4,i;
do
scanf("%d",&c);
if(c==4)
break;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
}
switch(c)
case 1:
bubble();
break;
case 2:
insertion();
break;
case 3:
selection();
break;
case 4:
break;
default:
for(i=0;i<n;i++)
printf("%d ",arr[i]);
}while(c!=4);
void bubble()
int i,j,t;
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
{
if(arr[j]>arr[j+1])
t=arr[j];
arr[j]=arr[j+1];
arr[j+1]=t;
void selection()
int i,j,t,min,temp;
for(i=0;i<n;i++)
min=arr[i];
t=i;
for(j=i+1;j<n;j++)
if(min>arr[j])
min=arr[j];
t=j;
temp=arr[t];
arr[t]=arr[i];
arr[i]=temp;
}
void insertion()
int j,y,t;
for(j=1;j<n;j++)
y=j-1;
t=arr[j];
arr[y+1]=arr[y];
y--;
arr[y+1]=t;
}
INPUT AND OUTPUT
ENTER YOUR CHOICE
1.BUBBLE SORT
2.INSERTION SORT
3.SELECTION SORT
4.EXIT
SORTED ARRAY IS
345
1.BUBBLE SORT
2.INSERTION SORT
3.SELECTION SORT
4.EXIT
56
47
89
23
SORTED ARRAY IS
1 4 5 23 47 56 89
1.BUBBLE SORT
2.INSERTION SORT
3.SELECTION SORT
4.EXIT
SORTED ARRAY IS
2345
1.BUBBLE SORT
2.INSERTION SORT
3.SELECTION SORT
4.EXIT
#include<stdio.h>
int pIndex;
void quicksort(int[],int,int);
int partition(int[],int,int);
void main(){
int A[50],n,i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&A[i]);
quicksort(A,0,n-1);
for(i=0;i<n;i++){
printf("%d ",A[i]);
if(start<end){
pIndex=partition(A,start,end);
quicksort(A,start,pIndex-1);
quicksort(A,pIndex+1,end);
}
int pivot,i,temp;
pivot=A[end];
pIndex=start;
for(i=start;i<=end-1;i++){
if(A[i]<=pivot){
temp=A[i];
A[i]=A[pIndex];
A[pIndex]=temp;
pIndex=pIndex+1;
temp=A[pIndex];
A[pIndex]=A[end];
A[end]=temp;
return pIndex;
}
INPUT AND OUTPUT
ENTER THE SIZE OF THE ARRAY
12 52 57 6 4 58 95
4 6 12 52 57 58 95
#include<stdio.h>
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
i = 0;
j = 0;
k = l;
if (L[i] <=R[j])
arr[k] = L[i];
i++;
else
arr[k]=R[j];
j++;
k++;
arr[k] = L[i];
i++;
k++;
arr[k] = R[j];
j++;
k++;
if (l < r){
int m = l+(r-l)/2;
mergeSort(arr, l, m);
merge(arr, l, m, r);
int i;
void main()
int choice,i;
do{
scanf("%d",&choice);
if(choice!=1)
break;
scanf("%d",&arr_size);
for(i=0;i<arr_size;i++){
scanf("%d",&A[i]);
}
printf("\n");
printArray(A, arr_size);
}while(choice==1);
}
INPUT AND OUTPUT
PROGRAM 6
CODE:
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node{
int data;
struct node *link;};
struct node *start=NULL;
temp->data=x;
temp->link=start;
start=temp;}
counter=start;
temp->data=x;
int i;
if (n>1){
for(i=1;i<n-1;i++)
counter=counter->link;
temp1=counter->link;
counter->link=temp;
temp->link=temp1;}
else{
temp->link=start;
start=temp;}}
void disp(){
struct node *counter;
counter=start;
while(counter!=NULL){
printf("%d ",counter->data);
counter=counter->link;}}
while(counter!=NULL){
if (x==counter->data){
printf("\nElement found at %d position\n",c);
flag=1;
break;}
c++;
counter=counter->link;}
return flag;}
if (x>1){
for(i=1;i<x-1;i++)
counter=counter->link;
temp=counter->link;
counter->link=temp->link;
free(temp);}
else{
start=start->link;
free(counter);}}
switch(c)
{
case 1: printf("\nEnter no of elements : ");
scanf("%d",&n);
printf("\nEnter %d elements \n",n);
for(i=0;i<n;i++){
printf("Enter element %d : ",i+1);
scanf("%d",&x);
insert(x);}
CODE:
#include<stdio.h>
switch(c)
{
case 1: top=-1;
printf("\nEnter no of elements : ");
scanf("%d",&size);
break;
case 2: pop(&top);
break;
while(res==1);
getch();
}
OUTPUT:
7.2: LINKED LIST IMPLEMENTATION OF STACK
CODE:
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node
{
int data;
struct node *link;
};
struct node *start=NULL;
void Push(int x)
{
struct node *temp=(struct node*)malloc(sizeof(struct node));
temp->data=x;
temp->link=start;
start=temp;
}
void Pop()
{
int i;
struct node *temp;
temp=start;
start=start->link;
free(temp);
}
void disp()
{
struct node *counter;
counter=start;
while(counter!=NULL)
{
printf("%d ",counter->data);
counter=counter->link;
}
}
int main ()
{
int d;
do
{
int n,i,x,c;
switch(c)
{
case 1: printf("\nEnter no of elements : ");
scanf("%d",&n);
Push(x);}
case 2: Pop();
printf("\nStack after Pop :\n ");
disp();
break;
while(d==1);
getch();
}
OUTPUT:
EXPERIMENT 8
CODE:
#include<stdio.h>
#include<conio.h>
int A[50];
int r=-1;
int f=-1;
else{
r++;
A[r]=x;}
}
void Disp(){
if(f==-1)
printf("\nQueue is empty !!!");
else{
int i;
printf("\nQueue : ");
void Delete(){
if(f==-1)
printf("\nUnderflow !!!");
else if (f==r){
f=-1;
r=-1;}
else
f++;
}
for(i=0;i<n;i++){
printf("Enter element %d : ",i+1);
scanf("%d",&x);
Insert(x,n);
}
Disp();
getch();
}
OUTPUT:
LINKED LIST IMPLEMENTATION OF QUEUE
CODE:
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node{
int data;
struct node *link;};
else{
rear->link=temp;
rear=temp;}
}
void Delete(){
if(front==NULL)
printf("Queue Empty");
else if(front==rear){
front=NULL;
rear=NULL;
free(temp);}
else{
front=front->link;
free(temp);}
}
void disp(){
struct node *counter;
counter=front;
while(counter!=rear){
printf("%d ",counter->data);
counter=counter->link;}
printf("%d ",counter->data);
}
int d;
do{
int n,i,x,c;
switch(c){
for(i=0;i<n;i++){
printf("Enter element %d : ",i+1);
scanf("%d",&x);
Insert(x);}
case 2: Delete();
OUTPUT:
Experiment-9
#include<stdio.h>
#include<stdlib.h>
struct node
{
int key;
struct node *left, *right;
};
struct node *newNode(int item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->key = item;
temp->left = temp->right = NULL;
return temp;
}
void inorder(struct node *root)
{
if (root != NULL)
{
inorder(root->left);
printf("%d ", root->key);
inorder(root->right);
}
}
struct node* insert(struct node* node, int key)
{
return node;
}
struct node *deletelement(struct node *root,int val)
{
struct node *par,*curr,*psuc,*suc,*ptr;
if(root==NULL)
{
printf("\ntree is empty\n");
return root;
}
par=root;
curr=root;
while(curr!=NULL&&val!=curr->key)
{
par=curr;
curr=(val<curr->key)?curr->left:curr->right;
}
if(curr == NULL)
{
printf("\n The value to be deleted is not present in the tree");
return root;
}
if(curr->left==NULL)
{
ptr=curr->right;
}
else if(curr->right==NULL)
{
ptr=curr->left;
}
else
{
psuc=curr;
suc=curr->right;
while(suc->left!=NULL)
{
psuc=suc;
suc=suc->left;
}
if(psuc==curr)
{
curr->right=suc->right;
curr->key=suc->key;
}
else
{
psuc->left=suc->right;
curr->key=suc->key;
}
curr=suc;
free(curr);
return root;
}
if(par->left==curr)
{
par->left=ptr;
}
else if(par->right==curr)
{
par->right=ptr;
}
free(curr);
return root;
}
void preorder(struct node *root)
{
if(root!=NULL)
{
printf("%d ", root->key);
preorder(root->left);
preorder(root->right);
}
}
void postorder(struct node *root)
{
if(root!=NULL)
{
postorder(root->left);
postorder(root->right);
printf("%d ",root->key);
}
}
int min_val(struct node *root)
{
struct node *curr;
curr=root;
while(curr->left!=NULL)
{
curr=curr->left;
}
return curr->key;
}
int max_val(struct node *root)
{
struct node *curr;
curr=root;
while(curr->right!=NULL)
{
curr=curr->right;
}
return curr->key;
}
// Driver Program to test above functions
int main()
{
int val,option;
struct node *root = NULL;
root = insert(root, 50);
insert(root, 30);
insert(root, 20);
insert(root, 40);
insert(root, 35);
insert(root, 70);
insert(root, 60);
insert(root, 80);
do
{
printf("\n ******MAIN MENU******* \n");
printf("\n 1. Insert Element");
printf("\t 2. Preorder Traversal");
printf("\n 3. Inorder Traversal");
printf("\t 4. Postorder Traversal");
printf("\n 5. smallest element");
printf("\t 6. largest element");
printf("\n 7. Delete an element");
printf("\n 8. Exit");
printf("\n\n Enter your option : ");
scanf("%d",&option);
switch(option)
{
case 1:printf("\nEnter the Element to be inserted ");
scanf("%d",&val);insert(root,val);break;
case 2:printf("\nPreorder traversal is :");
preorder(root);break;
case 3:printf("\nInorder traversal is :");
inorder(root);break;
case 4:printf("\nPostorder traversal is :");
postorder(root);break;
case 5:printf("\nSmallest element is : %d",min_val(root));break;
case 6:printf("\nLargest element is : %d",max_val(root));break;
case 7:printf("\nEnter the element to be deleted\n");
scanf("%d",&val);
root=deletelement(root,val);break;
case 8:break;
default:printf("Sorry.. Wrong Choice! Try again");
}
}
while(option!=8);
return 0;
}
OUTPUT:
Experiment 10
AIM : To implement Heap Sort in an array
CODE:
#include<stdio.h>
#define MAX 100
void heapSort(int arr[],int size);
void buildHeap(int arr[],int size);
int delRoot(int arr[],int *size);
void restoreDown(int arr[],int i,int size);
void display(int arr[],int n);
main()
{
int i,n,arr[MAX];
printf("Enter numberof elements: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter elements %d : ",i);
scanf("%d",&arr[i]);
}
printf("Entered list is :\n");
display(arr,n);
heapSort(arr,n);
printf("Sorted List is :\n");
display(arr,n);
}
void heapSort(int arr[],int size)
{
int max;
buildHeap(arr,size);
printf("Heap is :");
display(arr,size);
while(size>1)
{
max=delRoot(arr,&size);
arr[size+1]=max;
}
}
void buildHeap(int arr[],int size)
{
int i;
for(i=size/2;i>=1;i--)
{
restoreDown(arr,i,size);
}
}
int delRoot(int arr[],int (*size))
{
}
void restoreDown(int arr[],int i,int size)
{
int left=2*i,right =left +1;
int num=arr[i];
while(right<=size)
{
if(num>=arr[left]&&num>=arr[right])
{
arr[i]=num;
return;
}
else if(arr[left]>arr[right])
{
arr[i]=arr[left];
i=left;
}
else
{
arr[i]=arr[right];
i=right;
}
left=2*i;
right=left+1;
}
arr[i]=num;
}
void display(int arr[],int n)
{
int i;
for(i=1;i<=n;i++)
{
printf("%d ",arr[i]);
}
printf("\n");
}
OUTPUT:
Experiment-11
To perform Breadth First Search (BFS) on the graph using adjacency list.
CODE:
#include<stdio.h>
#include<stdlib.h>
#define initial 1
#define waiting 2
#define visited 3
int n;
int adj[MAX][MAX];
int state[MAX];
void create_graph();
void BF_Traversal();
void BFS(int v);
int main()
{
create_graph();
BF_Traversal();
return 0;
}
void BF_Traversal()
{
int v;
for(v=0; v<n; v++)
state[v] = initial;
printf("Enter Start Vertex for BFS: \n");
scanf("%d", &v);
BFS(v);
}
void BFS(int v)
{
int i;
insert_queue(v);
state[v] = waiting;
while(!isEmpty_queue())
{
v = delete_queue( );
printf("%d ",v);
state[v] = visited;
int isEmpty_queue()
{
if(front == -1 || front > rear)
return 1;
else
return 0;
}
int delete_queue()
{
int delete_item;
if(front == -1 || front > rear)
{
printf("Queue Underflow\n");
exit(1);
}
delete_item = queue[front];
front = front+1;
return delete_item;
}
void create_graph()
{
int count,max_edge,origin,destin;
printf("Enter number of vertices : ");
scanf("%d",&n);
max_edge = n*(n-1);
for(count=1; count<=max_edge; count++)
{
printf("Enter edge %d( -1 -1 to quit ) : ",count);
scanf("%d %d",&origin,&destin);
if((origin == -1) && (destin == -1))
break;
if(origin>=n || destin>=n || origin<0 || destin<0)
{
printf("Invalid edge!\n");
count--;
}
else
{
adj[origin][destin] = 1;
}
}
OUTPUT:
AIM:To implement DFS (Depth Breadth Search) on a graph.
To perform Depth First Search (DFS) on the graph using adjacency list.
CODE:
#include<stdio.h>
#include<stdlib.h>
node *G[20];
//heads of linked list
int visited[20];
int n;
void read_graph();
//create adjacency list
void insert(int,int);
//insert an edge (vi,vj) in te adjacency list
void DFS(int);
void main()
{
int i;
read_graph();
//initialised visited to 0
for(i=0;i<n;i++)
visited[i]=0;
DFS(0);
}
void DFS(int i)
{
node *p;
printf("\n%d",i);
p=G[i];
visited[i]=1;
while(p!=NULL)
{
i=p->vertex;
if(!visited[i])
DFS(i);
p=p->next;
}
}
void read_graph()
{
int i,vi,vj,no_of_edges;
printf("Enter number of vertices:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
G[i]=NULL;
//read edges and insert them in G[]
for(i=0;i<no_of_edges;i++)
{
printf("Enter an edge(u,v):");
scanf("%d%d",&vi,&vj);
insert(vi,vj);
}
}
}
while(p->next!=NULL)
p=p->next;
p->next=q;
}
}
OUTPUT: