Experiment Number-0 4: Student'S Name Student'S Uid Class and Group Semester
Experiment Number-0 4: Student'S Name Student'S Uid Class and Group Semester
Program to arrange the elements of an array in ascending order using insertion sort method.
PRACTICAL 4.2
Program to arrange the elements of an array in ascending order using merge sort method.
3.FLOWCHART/ALGORITHM:
Practical 4.1
5. Exit.
Practical 4.2
1. Set i=1,j=1,k=1
If(a[i]<b[j])
Else
C[k]=b[j]
J=j+1; k=k+1;
4. if(j>n)
Repeat steps till(I<=m)
[a] c[k]=a[I]
5. Exit
4.PROGRAM CODE:
Practical 4.1
#include<stdio.h>
int main()
int a[5],k,j,i,temp;
for(i=0;i<5;i++)
scanf("%d",&a[i]);
for(k=1;k<5;k++)
temp=a[k];
j=k-1;
while((a[j]<temp)&&(j>=0))
a[j+1]=a[j];
j=j-1;
a[j+1]=temp;
for(i=0;i<5;i++)
printf("%d\n",a[i]);
Practical 4.2
#include <stdio.h>
int a[10];
int b[10];
l1 = low;
l2 = mid + 1;
i = low;
b[i++] = a[l1++];
else
b[i++] = a[l2++];
b[i++] = a[l1++];
b[i++] = a[l2++];
a[i] = b[i];
int mid;
msort(low,mid);
msort(mid+1,high);
merging(low,mid,high);
int main()
Practical 4.1
Practical 4.2
The time complexity of the given Selection Sort program is O(n log n).
Practical 4.1
Practical 4.2
Analyze and compare the efficiency and properties of various data structures.
Design and employ appropriate data structures for solving computing problems.
Possess the ability to design efficient algorithms for solving computing problems.
4. Total Marks 20