DSA Lab5
DSA Lab5
1) Create a program that take an array of 10 inputs from the user and
generate the sorted output using the Insertion Sort Algorithms.
#include <iostream>
cout<<arr[i]<<" ";
cout<<endl;
int j = step - 1;
array[j + 1] = array[j];
--j;
array[j + 1] = key;
}
int main()
int arr[10];
cin>>arr[i];
insertionSort(arr, N);
printArray(arr, N);
return 0;
}
2) Take 10 inputs from the user and assign them into two arrays (make 2
arrays of 5 lengths each), merge those arrays and obtain the result in
the sorted manner by using insertion sort.
#include<iostream>
cout<<arr[i]<<" ";
cout<<endl;
int j = step - 1;
array[j + 1] = array[j];
--j;
array[j + 1] = key;
}
int main()
int i, k;
cin>>a[i];
arr[i] = a[i];
k = i;
cin>>b[i];
arr[k] = b[i];
k++;
cout<<endl;
cout<<arr[i]<<" ";
}
cout<<endl;
insertionSort(arr, N);
cout<<endl;
printArray(arr, N);
return 0;