Data Structure

Write a program to sort elements of given array having ‘n’ numbers of element, using Selection sort. Data Structure

Write a program to sort elements of given array having ‘n’ numbers of element, using Selection sort.

Write a program to sort elements of given array having ‘n’ numbers of elements, using Selection sort. #include #include void main() { clrscr(); int size, arr[50], i, j, temp; cout<>size; cout<<“Enter Array Elements : “; for(i=0; i>arr[i]; } cout<<“Sorting array using selection sort…n”; for(i=0; i<size; i++) { for(j=i+1; jarr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } } […]

Write a program to implement the concept of pointer to array access in functions.

#include #include main() { int *p,i,n; void modify(int *,int); clrscr(); cout<>n; for(i=0;i<n;i++) { cout<<"n A["<<i<>*(p+i); } cout<<"nnn"; cout<<"n Before calling the function for modification elements are :n"; for(i=0;i<n;i++) { cout<<"n A["<<i<<"]="<<*(p+i); } modify(p,n); cout<<"n After modification each element incremented by 500 n"; for(i=0;i<n;i++) { cout<<"n A["<<i<<"]="<<*(p+i); } getch(); return(0); } void modify(int *t, int s) […]

Write a program to sort elements of given array having ‘n’ number of elements,using Merge Sort.

#include #include main() { int a[50],c[100],n,i; void merge(int *,int,int); void mr(int*,int,int,int,int); clrscr(); cout<>n; cout<<"n Enter the elements of array n"; for(i=0;i<n;i++) { cout<<"n a["<<i<>a[i]; } merge(a,0,n-1); cout<<"nnn MERGED ARRAY IN ASCENDING ORDER IS n"; for(i=0;i<n;i++) { cout<<"n A["<<i<<"]="<<a[i]; } getch(); return(0); } void mr(int *a,int lb,int le,int rb,int re) { cout<<"n FROM MERGING n"; cout<<"nn […]