SlideShare a Scribd company logo
1 of 29
Download to read offline
Homework Assignment 1 
ICT:5102, Data Structure & Algorithm 
 
Md.Dedarul Hasan 
PGD in IT, Registration No: 0417311011 
Session: April,2017 
 
 
 
 
 
INTRODUCTION OF TASK TO DO 
Insertion Sort, Merge Sort & Quick Sort Algorithms.Total Comparison & Swap Count                       
During Sort Proces. Array Sorting By Ascending, Descending & Random Order                     
Implementations. 
GIVEN INPUT ARRAY 
{195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162,165, 
192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121, 178, 119, 128, 193, 127, 123, 143, 
155, 186,191, 122, 132, 158, 129, 183, 163, 180, 103, 188, 150, 151, 172, 118, 174, 170, 104, 
130, 116, 117,112, 139, 194, 147, 153, 164, 169, 199, 148, 138, 200, 190, 126, 152, 161, 179, 
149, 137, 133, 110,159, 113, 140, 160, 105, 184, 182, 135, 114, 125, 168, 189, 124, 108, 187, 
166, 156, 109, 167, 157} 
 
 
 
 
 
 
 
 
1   
CODE FOR INSERTION SORT WITH COMPARISON & SWAP 
#include <stdio.h> 
#include <math.h> 
int comparsioncounter=0; 
int swapcounter=0; 
//METHOD FOR INSERTION 
SORT****************************************************************************************
*************// 
void insertionSort(int arr[], int size){ 
int i, key, j; 
for (i = 1; i <size; i++){ 
comparsioncounter++; 
key = arr[i]; 
j = i-1; 
while (j >= 0 && arr[j] > key) 
{ 
comparsioncounter++; 
arr[j+1] = arr[j]; 
swapcounter++; 
j = j-1; 
} 
arr[j+1] = key; 
swapcounter++; 
} 
} 
2   
//METHOD TO PRINT AN ARRAY OF SIZE n 
********************************************************************************************// 
void printArray(int arr[], int size){ 
int i; 
for (i=0; i < size; i++) 
printf("%d ", arr[i]); 
printf("n"); 
} 
// MAIN METHOD TO EXECUTE INSERTION 
SORT****************************************************************************************
*// 
int main(){ 
int arr[100] = 
{195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162,165, 192,131, 
142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 155 ,186,191, 122 
,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 130, 116, 117,112 ,139 ,194, 
147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 ,149 ,137 ,133 ,110,159 ,113, 140 ,160 
,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 ,166 ,156 ,109 ,167 ,157}; 
//int arr[] = {12, 11, 13, 5, 6}; 
//int arr[] = {29, 10, 14, 37, 6}; 
int arr_size = sizeof(arr)/sizeof(arr[0]); 
printf("GIVEN ARRAY WHICH HAVE TO BE SORTED: nn"); 
printArray(arr, arr_size); 
//PRINT INSERTION 
SORT****************************************************************************************
************// 
printf("nSORTED ARRAY USING INSERTION SORT ALGORITHM IS:nn"); 
insertionSort(arr, arr_size); 
3   
printArray(arr, arr_size); 
//PRINT THE NUMBER OF COMPARISONS AND 
SWAPS********************************************************************************// 
printf("nnNUMBER OF COMPARISONS IS: %dnn", comparsioncounter); 
printf("NUMBER OF SWAP IS : %dn", swapcounter); 
return 0; 
} 
 
OUTPUT: 
Fig :1- Insertion sort in ascending 
 
 
 
4   
 
CODE FOR MERGE SORT WITH COMPARISON & SWAP 
#include<stdlib.h> 
#include<stdio.h> 
//MARGE SORT PROGRAM 
int comparsioncounter=0; 
int swapcounter=0; 
int swapcounter1=0; 
//METHOD FOR MERGE 
SORT********************************************************************************
**************************// 
void merge(int arr[], int l, int m, int r){ 
int i, j, k; 
int n1 = m - l + 1; 
int n2 = r - m; 
//CREATE TEMP ARRAY 
int L[n1], R[n2]; 
/* COPY DATA TO TEMP ARRAYS L[] and R[] */ 
for (i = 0; i < n1; i++) 
L[i] = arr[l + i]; 
for (j = 0; j < n2; j++) 
R[j] = arr[m + 1+ j]; 
/* MARGE THE TEMP ARRAYS BACK INTO ARRAY [l...r]*/ 
5   
i = 0; 
j = 0; 
k = l; 
while (i < n1 && j < n2){ 
if (L[i] <= R[j]){ 
arr[k] = L[i]; 
i++; 
} 
else{ 
arr[k] = R[j]; 
swapcounter++; 
j++; 
} 
comparsioncounter++; 
k++; 
} 
/* COPY THE REMAINING ELEMENTS OF L[],IF THERE ARE ANY */ 
while (i < n1){ 
arr[k] = L[i]; 
i++; 
k++; 
//count3++; 
} 
/* COPY THE REMAINING ELEMENTS OF R[],ANY IF THERE ANY */ 
6   
while (j < n2){ 
arr[k] = R[j]; 
j++; 
k++; 
//count4++; 
} 
//printArray(arr, n); 
//printf("Number of comparsions is %dn", count1+count2+count3+count4); 
//printf("Number of swaps is %dn", swapcount); 
} 
/* l IS FOR LEFT INDEX and r IS FOR RIGHT INDEX OF THE SUB ARRAY OF arr HAVE TO 
BE SORTED */ 
void mergeSort(int arr[], int l, int r){ 
if (l < r){ 
int m = l+(r-l)/2; 
// SORT FIRST & LAST HALVES 
mergeSort(arr, l, m); 
mergeSort(arr, m+1, r); 
merge(arr, l, m, r); 
} 
} 
/* UTILITY FUNCTIONS */ 
/* PRINT ARRAY */ 
void printArray(int A[], int size){ 
7   
int i; 
for (i=0; i < size; i++) 
printf("%d ", A[i]); 
printf("n"); 
} 
//MAIN METHOD 
*************************************************************************************
*******************************// 
int main(){ 
int arr[]= 
{195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165, 
192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 
155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 
130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 
,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 
,166 ,156 ,109 ,167 ,157}; 
//int arr[] = {12, 11, 13, 5, 6, 7}; 
//int arr[] = {3,2,1,5,4,8}; 
//int arr[] = {38,27,43,3,9,82,10}; 
int arr_size = sizeof(arr)/sizeof(arr[0]); 
printf("GIVEN ARRAY WHICH HAVE TO BE SORT IS: nn"); 
printArray(arr, arr_size); 
//MARGE SORTING 
METHOD****************************************************************************
******************************// 
mergeSort(arr, 0, arr_size - 1); 
printf("nSORTED ARRAY USING MARGE SORT ALGORITHM IS:nn"); 
8   
printArray(arr, arr_size); 
//PRINT TOTAL COMPARISON AND SWAP 
COUNT******************************************************************************
***********// 
printf("Number of comparsions is %dn", comparsioncounter); 
printf("Number of swap is %dn", swapcounter); 
return 0; 
} 
OUTPUT: 
Fig :2- Merge sort in ascending 
 
 
 
9   
 
 
CODE FOR QUICK SORT WITH COMPARISON & SWAP 
#include<stdio.h> 
//QUICK SORT PROGRAM C CODE 
// FUNCTION SWAP TWO ELEMENTS 
int comparsioncounter=0; 
int swapcounter=0; 
//METHOD FOR SWAP 
*************************************************************************************
**************************// 
void swap(int* a, int* b){ 
int t = *a; 
*a = *b; 
*b = t; 
} 
// THIS FUNCTION TAKES LAST ELEMENTS AS PIVOT ,PLACES THE PIVOT ELEMENT AT 
ITS CORRECT POSITION IN SORTED ARRAY******************// 
//AND PLACES ALL SMALLER [SMALLER THAN PIVOT] TO LEFT OF PIVOT AND ALL 
GREATER ELEMENTS TO RIGHT OF PIVOT************************// 
int partition (int arr[], int low, int high){ 
int pivot = arr[high]; 
int i = (low - 1); 
10   
for (int j = low; j <= high- 1; j++){ 
comparsioncounter++; 
if (arr[j] <= pivot) 
{ 
i++; 
swap(&arr[i], &arr[j]); 
swapcounter++; 
} 
} 
swap(&arr[i + 1], &arr[high]); 
return (i + 1); 
} 
// ARRAY TO BE SORTED, LOW-->STARTING INDEX, HIGH-->ENDING 
INDEX*****************************************************************// 
void quickSort(int arr[], int low, int high){ 
if (low < high){ 
int pi = partition(arr, low, high); 
quickSort(arr, low, pi - 1); 
quickSort(arr, pi + 1, high); 
} 
} 
//PRINT 
ARRAY******************************************************************************
*************************************// 
void printArray(int arr[], int size){ 
11   
for (int i=0; i <=size; i++) 
printf("%d ", arr[i]); 
printf("n"); 
} 
// MAIN 
METHOD****************************************************************************
**************************************// 
int main(){ 
int arr[]= 
{195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165, 
192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 
155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 
130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 
,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 
,166 ,156 ,109 ,167 ,157}; 
//int arr[] = {10, 7, 8, 9, 1, 5}; 
//int arr[] = {38,27,43,3,9,82,10}; 
//int arr[] ={10, 80, 30, 90, 40, 50, 70}; 
int arr_size = sizeof(arr)/sizeof(arr[0]); 
printf("GIVEN ARRAY WHICH HAVE TO BE SORTED: nn"); 
printArray(arr, arr_size); 
//QUICK SORT 
METHOD****************************************************************************
*********************************// 
quickSort(arr, 0, arr_size-1); 
printf("QUICK SORTED ARRAY IS : nn"); 
printArray(arr, arr_size); 
12   
//PRINT THE NUMBER OF COMPARISONS AND 
SWAPS******************************************************************************
********// 
printf("nnNUMBER OF COMPARISONS IS: %dnn", comparsioncounter); 
printf("NUMBER OF SWAP IS : %dn", swapcounter); 
return 0; 
} 
 
 
OUTPUT: 
Fig :3- Quick sort in ascending order 
 
 
 
 
13   
 
 
 
 
CODE FOR [101-200] SORT IN ASCENDING ORDER 
#include <stdio.h> 
//PRINT 
ARRAY******************************************************************************
************************************// 
void printArray(int arr[], int size){ 
int i; 
for (i=0; i < size; i++) 
printf("%d ", arr[i]); 
printf("n"); 
} 
//MAIN 
METHOD****************************************************************************
***************************************// 
int main(){ 
int arr[100]= 
{195,134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165, 
192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 
155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 
130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 
,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 
,166 ,156 ,109 ,167 ,157}; 
14   
int temp=0; 
int arr_size = sizeof(arr)/sizeof(arr[0]); 
//PRINT THE GIVEN ARRAY 
printf("GIVEN ARRAY WHICH HAVE TO BE SORT IS: n"); 
printArray(arr, arr_size); 
// CODE FOR ASCENDING ORDER OF ARRAY ELEMENT 
for (int i = 0; i < arr_size; i++){ 
for (int j = i+1; j < arr_size; j++){ 
if (arr[j] < arr[i]){ 
int tmp = arr[i]; //Using temporary variable for storing   
arr[i] = arr[j]; //replacing value 
arr[j] = tmp; 
} 
} 
} 
//PRINT ARRAY IN ASCENDING 
ORDER******************************************************************************
*******************// 
printf("nALREADY IN ASCENDING SORT OF THAT ARRAY:n"); 
for(int i=0; i< arr_size; i++){ 
printf("%d ",arr[i]); 
} 
return 0; 
} 
15   
 
 
 
OUTPUT: 
Fig :4- [101-200] array in ascending order 
 
 
 
CODE FOR [200-101] SORT IN DESCENDING ORDER 
#include <stdio.h> 
//PRINT 
ARRAY******************************************************************************
*************************************// 
16   
void printArray(int arr[], int size){ 
int i; 
for (i=0; i < size; i++) 
printf("%d ", arr[i]); 
printf("n"); 
} 
//MAIN 
METHOD****************************************************************************
***************************************// 
int main(){ 
int arr[100]= 
{195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165, 
192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 
155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 
130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 
,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 
,166 ,156 ,109 ,167 ,157}; 
int temp=0; 
int arr_size = sizeof(arr)/sizeof(arr[0]); 
//PRINT THE GIVEN 
ARRAY******************************************************************************
***************************// 
printf("GIVEN ARRAY WHICH HAVE TO BE SORT IS: nn"); 
printArray(arr, arr_size); 
// CODE FOR ASCENDING ORDER OF ARRAY ELEMENT 
for (int i = 0; i < arr_size; i++){ 
for (int j = i+1; j < arr_size; j++){ 
17   
if (arr[j] > arr[i]){ 
int tmp = arr[i]; //Using temporary variable for storing 
last value 
arr[i] = arr[j]; //replacing value 
arr[j] = tmp; 
} 
} 
} 
//PRINT ARRAY IN DESCENDING 
ORDER******************************************************************************
*****************// 
printf("nALREADY IN DESCENDING SORT OF THAT ARRAY:n"); 
printf("n"); 
for(int i=0; i< arr_size; i++){ 
printf("%d ",arr[i]); 
} 
printf("n"); 
return 0; 
} 
 
 
 
 
 
18   
OUTPUT: 
Fig :5- [200-101] like descending order 
 
 
CODE FOR [101-200] SORT IN RANDOM ORDER 
#include <stdio.h> 
#include <stdlib.h> 
#include <time.h> 
//101-200 SORT USING THE RANDOM FUNCTION 
// FUNCTION TO SWAP THE INTEGER ARRAY ELEMENT to swap to integers 
//METHOD FOR 
SWAP*******************************************************************************
********************************// 
19   
void swap (int *a, int *b){ 
int temp = *a; 
*a = *b; 
*b = temp; 
} 
// PRINT ARRAY 
FUNCTIOKN*************************************************************************
*******************************// 
void printArray (int arr[], int size){ 
for (int i = 0; i < size; i++) 
printf("%d ", arr[i]); 
printf("n"); 
} 
// A FUNCTION TO GENERATE A RANDOM 
NUMBERS***************************************************************************
***********// 
void randomize ( int arr[], int n ){ 
srand ( time(NULL) ); 
for (int i = n-1; i > 0; i--){ 
// PIC A RANDOM INDEX FROM 0 TO i 
int j = rand() % (i+1); 
// SWAP arr[i] WITH THE ELEMENT AT RANDOM INDEXS 
swap(&arr[i], &arr[j]); 
} 
} 
20   
//MAIN 
METHOD****************************************************************************
***************************************// 
int main(){ 
int arr[100] = 
{195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165, 
192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 
155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 
130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 
,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 
,166 ,156 ,109 ,167 ,157}; 
//int i; 
int arr_size = sizeof(arr)/sizeof(arr[0]); 
printf("GIVEN ARRAY WHICH HAVE TO BE REARANGE WITH RANDOM: n"); 
printf("n"); 
for(int i = 0; i < arr_size; i++){ 
printf("%d ", arr[i]); 
} 
//PRINT RANDOM ARRAY 
ELEMENT***************************************************************************
*************************// 
printf("n"); 
printf("nSORTED USING RANDOM SORT IS : nn"); 
int n = sizeof(arr)/ sizeof(arr[0]); 
randomize (arr, n); 
printArray(arr, n); 
printf("n"); 
21   
return 0; 
} 
 
 
OUTPUT: 
Fig :6- [101-200] array sort in random order 
 
 
 
 
 
 
 
22   
MATERIALS 
1. Code Block IDE Tools 
2. GDB/CDB debugger 
3. IntelliJ IDE/Netbeans IDE 
4. JDK 
PROCEDURE 
1. C Programming 
2. C++ Programming 
3. Java Programming 
 
OUTPUT DATA REPORT FOR TOTAL COMPARISONS & SWAPS COUNT: 
ALGORITHM  NO OF COMPARISONS  NO OF SWAPS 
Insertion Sort     
Merge Sort     
Quick Sort     
RESULTS 
We have used C programming language for that assignment completions. Which has                       
given the ultimate result for Insertion Sort, Merge Sort & Quick Sort using their algorithm                             
& pseudo codes. After that we have sorted the given input array [101-200] in Ascending                             
,Descending & also Randomize options too. 
 
23   
CONCLUSION 
 
1. Insert sort is more efficient than bubble sort and selection sort.In this algo we 
divide the entire array into parts; the sorted array and the unsorted array.With 
every iteration we have to place the first element of the unsorted array in the 
correct position of the sorted array and increase the sorted list by one. 
Time Complexity: 
when elements are sorted there are no swaps and the correct position of the                           
element in the sorted list is the current index itself.The time complexity is : O(n) 
Insertion sort gets penalized if comparison or copying is slow. In other words, the                           
maximum array size which is faster to sort with insertion sort compared to                         
O(nlogn) algorithms gets smaller if comparison or copying of the array elements is                         
slow. 
Divide and Conquer Approach- 
In this approach the algorithm is divide into multiple sub-problems.Each of these                       
sub-problems is then solved separately and the solution of each sub-problem is                       
used to solve the original problem. 
Divide and conquer technique uses recursion to solve each of the sub-problem. 
 
 
 
 
 
 
 
 
24   
Fig : Insertion Sort Time Complexity 
 
2. Merge sort uses the divide and conquer approach.It is one of the most efficient                           
algo for sorting.In this algo,we divide the list into two from the middle and keep                             
dividing the list until the sub-problems has only one element list. 
We then merge the list and while merging the list we sort them in the ascending                               
order. 
Time complexity: 
We are dividing the list into no matter if the list is sorted or no.But if the array is                                     
sorted,while merging the list there are no swaps merging results into an array                         
itself.Thus, the best ,average and worst case time complexity is: O(nlogn) 
Surprisingly fast, at least with the optimizations used in this test (ie. the sorting                           
function doesn't need to allocate the secondary array each time it is called). Given                           
that it is always O(nlogn), it is a very good alternative if the extra memory                             
requirement is not a problem. 
Array elements with fast comparisons and slow copying seem to slightly penalize                       
merge sort. 
25   
Fig: Merge Sort Time Complexity 
 
3. Quick sort uses the similar approach of divide and conquer technique 
In this technique, element is selected which is the pivot element.Now the element                         
which are less than the pivot are placed to the left of the array and the element                                 
which are more than the pivot are placed to the right of the pivot.The index of the                                 
pivot element is then returned back to the function.The same function is called to                           
the sub-array left to the pivot which has all the elements less than the pivot and                               
also to the right of the sub-array which has the elements more than the pivot. 
After calling the function recursively,the resulting function will be a sorted array. 
Time complexity: 
The best case is when the elements are in a sorted manner. The best and average                               
case time complexity is : O(nlogn) 
The worst case time complexity is when the elements are in a reverse sorted                           
manner.The time complexity is :O(n2) 
In this Quick Sort,the last element in the list is taken as the pivot element.This                             
Quick Sort is a bit slow as compared to other approaches of Quick Sort. 
26   
 
Fig: Quick Sort Time Complexity 
 
4. For Random sort approach,Most of the times this is going to be the approach                           
since we are going to sort random number elements 
Other sort,should never be employed.They take hours to sort a million                     
elements.We can see that by the readings provided in the zip file of the                           
assignment 5 folder. 
Merge sort performs very well for this sort.It should be employed. 
Also the quick sort algorithm performs very well for a million elements.All three                         
approaches of quick sort are pretty fast and any of them can be                         
employed.However,if one requires very good efficiency,he should use Quicksort                 
pivot-median approach. 
 
 
 
27   
 
Fig: Random Sort Time Complexity 
 
REFERENCES 
1. Class Lectures & pseudo-codes 
2. Stack Overflow 
3. GeeksforGeeks 
4. Other Blog Sites 
5. Books Help 
 
28   

More Related Content

Similar to Home workassignment 1 report google docs

check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfangelfragranc
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
Mtk khoirul bab 1
Mtk khoirul bab 1Mtk khoirul bab 1
Mtk khoirul bab 1Zinoa
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfshreeaadithyaacellso
 
i am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdfi am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdfANJALIENTERPRISES1
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semesterDOSONKA Group
 
#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdfANSAPPARELS
 
SP-First-Lecture.ppt
SP-First-Lecture.pptSP-First-Lecture.ppt
SP-First-Lecture.pptFareedIhsas
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdfapleather
 
Janusz Korczak - wykaz książek i artykułów w zbiorach BP Cieszyn
Janusz Korczak - wykaz książek i artykułów w zbiorach BP CieszynJanusz Korczak - wykaz książek i artykułów w zbiorach BP Cieszyn
Janusz Korczak - wykaz książek i artykułów w zbiorach BP CieszynMultimedia Lab - Pedagogical Library
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CSAAKASH KUMAR
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfbadshetoms
 
LEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACING
LEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACINGLEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACING
LEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACINGLeona Chin
 
#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docxajoy21
 
Distributed Object Computing
Distributed Object ComputingDistributed Object Computing
Distributed Object ComputingEmmanuel Fuchs
 

Similar to Home workassignment 1 report google docs (20)

check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdf
 
Vcs17
Vcs17Vcs17
Vcs17
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Mtk khoirul bab 1
Mtk khoirul bab 1Mtk khoirul bab 1
Mtk khoirul bab 1
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Toan t1
Toan t1Toan t1
Toan t1
 
Lab Question
Lab QuestionLab Question
Lab Question
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
i am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdfi am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdf
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf
 
SP-First-Lecture.ppt
SP-First-Lecture.pptSP-First-Lecture.ppt
SP-First-Lecture.ppt
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
 
Janusz Korczak - wykaz książek i artykułów w zbiorach BP Cieszyn
Janusz Korczak - wykaz książek i artykułów w zbiorach BP CieszynJanusz Korczak - wykaz książek i artykułów w zbiorach BP Cieszyn
Janusz Korczak - wykaz książek i artykułów w zbiorach BP Cieszyn
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
oodp elab.pdf
oodp elab.pdfoodp elab.pdf
oodp elab.pdf
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdf
 
LEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACING
LEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACINGLEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACING
LEONA CHIN BECOMES TEAM MANAGER FOR MUDAH RACING
 
#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx
 
Distributed Object Computing
Distributed Object ComputingDistributed Object Computing
Distributed Object Computing
 

More from LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.

More from LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD. (20)

লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALLলালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
 
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALLলালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
 
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ ৩৬ নং আইন, ২০২৩,
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ  ৩৬ নং আইন, ২০২৩, ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ  ৩৬ নং আইন, ২০২৩,
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ ৩৬ নং আইন, ২০২৩,
 
CrPC BARE ACT -1898 BANGLA.pdf
CrPC BARE ACT -1898  BANGLA.pdfCrPC BARE ACT -1898  BANGLA.pdf
CrPC BARE ACT -1898 BANGLA.pdf
 
CPC BARE ACT -1908 BANGLA.pdf
CPC BARE ACT -1908  BANGLA.pdfCPC BARE ACT -1908  BANGLA.pdf
CPC BARE ACT -1908 BANGLA.pdf
 
PC BARE ACT -1860 BANGLA.pdf
PC BARE ACT -1860  BANGLA.pdfPC BARE ACT -1860  BANGLA.pdf
PC BARE ACT -1860 BANGLA.pdf
 
SR BARE ACT -1877 BANGLA.pdf
SR BARE ACT -1877  BANGLA.pdfSR BARE ACT -1877  BANGLA.pdf
SR BARE ACT -1877 BANGLA.pdf
 
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdfThe Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
 
LA BARE ACT -1908 BANGLA.pdf
LA BARE ACT -1908  BANGLA.pdfLA BARE ACT -1908  BANGLA.pdf
LA BARE ACT -1908 BANGLA.pdf
 
EA BARE ACT -1872 BANGLA.pdf
EA BARE ACT -1872  BANGLA.pdfEA BARE ACT -1872  BANGLA.pdf
EA BARE ACT -1872 BANGLA.pdf
 
DIGITAL COMMERCE LAWS & RULES 2021.docx
DIGITAL COMMERCE LAWS & RULES 2021.docxDIGITAL COMMERCE LAWS & RULES 2021.docx
DIGITAL COMMERCE LAWS & RULES 2021.docx
 
Programming Your Home Automate with Arduino, Android, and Your Computer.pdf
Programming Your Home Automate with Arduino, Android, and Your Computer.pdfProgramming Your Home Automate with Arduino, Android, and Your Computer.pdf
Programming Your Home Automate with Arduino, Android, and Your Computer.pdf
 
Web site Review & Description by tanbircox.pdf
Web site Review & Description by tanbircox.pdfWeb site Review & Description by tanbircox.pdf
Web site Review & Description by tanbircox.pdf
 
Basic Electronics.pdf
Basic Electronics.pdfBasic Electronics.pdf
Basic Electronics.pdf
 
Circuit book_PP.pdf
Circuit book_PP.pdfCircuit book_PP.pdf
Circuit book_PP.pdf
 
Microcontroller.pdf
Microcontroller.pdfMicrocontroller.pdf
Microcontroller.pdf
 
Digital_electronics_dynamic.pdf
Digital_electronics_dynamic.pdfDigital_electronics_dynamic.pdf
Digital_electronics_dynamic.pdf
 
Project Electronics_Copy.pdf
Project Electronics_Copy.pdfProject Electronics_Copy.pdf
Project Electronics_Copy.pdf
 
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docxবিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
 
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docxসুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
 

Recently uploaded

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfrs7054576148
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 

Recently uploaded (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 

Home workassignment 1 report google docs

  • 1. Homework Assignment 1  ICT:5102, Data Structure & Algorithm    Md.Dedarul Hasan  PGD in IT, Registration No: 0417311011  Session: April,2017           
  • 2. INTRODUCTION OF TASK TO DO  Insertion Sort, Merge Sort & Quick Sort Algorithms.Total Comparison & Swap Count                        During Sort Proces. Array Sorting By Ascending, Descending & Random Order                      Implementations.  GIVEN INPUT ARRAY  {195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162,165,  192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121, 178, 119, 128, 193, 127, 123, 143,  155, 186,191, 122, 132, 158, 129, 183, 163, 180, 103, 188, 150, 151, 172, 118, 174, 170, 104,  130, 116, 117,112, 139, 194, 147, 153, 164, 169, 199, 148, 138, 200, 190, 126, 152, 161, 179,  149, 137, 133, 110,159, 113, 140, 160, 105, 184, 182, 135, 114, 125, 168, 189, 124, 108, 187,  166, 156, 109, 167, 157}                  1   
  • 3. CODE FOR INSERTION SORT WITH COMPARISON & SWAP  #include <stdio.h>  #include <math.h>  int comparsioncounter=0;  int swapcounter=0;  //METHOD FOR INSERTION  SORT**************************************************************************************** *************//  void insertionSort(int arr[], int size){  int i, key, j;  for (i = 1; i <size; i++){  comparsioncounter++;  key = arr[i];  j = i-1;  while (j >= 0 && arr[j] > key)  {  comparsioncounter++;  arr[j+1] = arr[j];  swapcounter++;  j = j-1;  }  arr[j+1] = key;  swapcounter++;  }  }  2   
  • 4. //METHOD TO PRINT AN ARRAY OF SIZE n  ********************************************************************************************//  void printArray(int arr[], int size){  int i;  for (i=0; i < size; i++)  printf("%d ", arr[i]);  printf("n");  }  // MAIN METHOD TO EXECUTE INSERTION  SORT**************************************************************************************** *//  int main(){  int arr[100] =  {195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162,165, 192,131,  142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143, 155 ,186,191, 122  ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104, 130, 116, 117,112 ,139 ,194,  147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179 ,149 ,137 ,133 ,110,159 ,113, 140 ,160  ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187 ,166 ,156 ,109 ,167 ,157};  //int arr[] = {12, 11, 13, 5, 6};  //int arr[] = {29, 10, 14, 37, 6};  int arr_size = sizeof(arr)/sizeof(arr[0]);  printf("GIVEN ARRAY WHICH HAVE TO BE SORTED: nn");  printArray(arr, arr_size);  //PRINT INSERTION  SORT**************************************************************************************** ************//  printf("nSORTED ARRAY USING INSERTION SORT ALGORITHM IS:nn");  insertionSort(arr, arr_size);  3   
  • 5. printArray(arr, arr_size);  //PRINT THE NUMBER OF COMPARISONS AND  SWAPS********************************************************************************//  printf("nnNUMBER OF COMPARISONS IS: %dnn", comparsioncounter);  printf("NUMBER OF SWAP IS : %dn", swapcounter);  return 0;  }    OUTPUT:  Fig :1- Insertion sort in ascending        4   
  • 6.   CODE FOR MERGE SORT WITH COMPARISON & SWAP  #include<stdlib.h>  #include<stdio.h>  //MARGE SORT PROGRAM  int comparsioncounter=0;  int swapcounter=0;  int swapcounter1=0;  //METHOD FOR MERGE  SORT******************************************************************************** **************************//  void merge(int arr[], int l, int m, int r){  int i, j, k;  int n1 = m - l + 1;  int n2 = r - m;  //CREATE TEMP ARRAY  int L[n1], R[n2];  /* COPY DATA TO TEMP ARRAYS L[] and R[] */  for (i = 0; i < n1; i++)  L[i] = arr[l + i];  for (j = 0; j < n2; j++)  R[j] = arr[m + 1+ j];  /* MARGE THE TEMP ARRAYS BACK INTO ARRAY [l...r]*/  5   
  • 7. i = 0;  j = 0;  k = l;  while (i < n1 && j < n2){  if (L[i] <= R[j]){  arr[k] = L[i];  i++;  }  else{  arr[k] = R[j];  swapcounter++;  j++;  }  comparsioncounter++;  k++;  }  /* COPY THE REMAINING ELEMENTS OF L[],IF THERE ARE ANY */  while (i < n1){  arr[k] = L[i];  i++;  k++;  //count3++;  }  /* COPY THE REMAINING ELEMENTS OF R[],ANY IF THERE ANY */  6   
  • 8. while (j < n2){  arr[k] = R[j];  j++;  k++;  //count4++;  }  //printArray(arr, n);  //printf("Number of comparsions is %dn", count1+count2+count3+count4);  //printf("Number of swaps is %dn", swapcount);  }  /* l IS FOR LEFT INDEX and r IS FOR RIGHT INDEX OF THE SUB ARRAY OF arr HAVE TO  BE SORTED */  void mergeSort(int arr[], int l, int r){  if (l < r){  int m = l+(r-l)/2;  // SORT FIRST & LAST HALVES  mergeSort(arr, l, m);  mergeSort(arr, m+1, r);  merge(arr, l, m, r);  }  }  /* UTILITY FUNCTIONS */  /* PRINT ARRAY */  void printArray(int A[], int size){  7   
  • 9. int i;  for (i=0; i < size; i++)  printf("%d ", A[i]);  printf("n");  }  //MAIN METHOD  ************************************************************************************* *******************************//  int main(){  int arr[]=  {195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165,  192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143,  155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104,  130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179  ,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187  ,166 ,156 ,109 ,167 ,157};  //int arr[] = {12, 11, 13, 5, 6, 7};  //int arr[] = {3,2,1,5,4,8};  //int arr[] = {38,27,43,3,9,82,10};  int arr_size = sizeof(arr)/sizeof(arr[0]);  printf("GIVEN ARRAY WHICH HAVE TO BE SORT IS: nn");  printArray(arr, arr_size);  //MARGE SORTING  METHOD**************************************************************************** ******************************//  mergeSort(arr, 0, arr_size - 1);  printf("nSORTED ARRAY USING MARGE SORT ALGORITHM IS:nn");  8   
  • 10. printArray(arr, arr_size);  //PRINT TOTAL COMPARISON AND SWAP  COUNT****************************************************************************** ***********//  printf("Number of comparsions is %dn", comparsioncounter);  printf("Number of swap is %dn", swapcounter);  return 0;  }  OUTPUT:  Fig :2- Merge sort in ascending        9   
  • 11.     CODE FOR QUICK SORT WITH COMPARISON & SWAP  #include<stdio.h>  //QUICK SORT PROGRAM C CODE  // FUNCTION SWAP TWO ELEMENTS  int comparsioncounter=0;  int swapcounter=0;  //METHOD FOR SWAP  ************************************************************************************* **************************//  void swap(int* a, int* b){  int t = *a;  *a = *b;  *b = t;  }  // THIS FUNCTION TAKES LAST ELEMENTS AS PIVOT ,PLACES THE PIVOT ELEMENT AT  ITS CORRECT POSITION IN SORTED ARRAY******************//  //AND PLACES ALL SMALLER [SMALLER THAN PIVOT] TO LEFT OF PIVOT AND ALL  GREATER ELEMENTS TO RIGHT OF PIVOT************************//  int partition (int arr[], int low, int high){  int pivot = arr[high];  int i = (low - 1);  10   
  • 12. for (int j = low; j <= high- 1; j++){  comparsioncounter++;  if (arr[j] <= pivot)  {  i++;  swap(&arr[i], &arr[j]);  swapcounter++;  }  }  swap(&arr[i + 1], &arr[high]);  return (i + 1);  }  // ARRAY TO BE SORTED, LOW-->STARTING INDEX, HIGH-->ENDING  INDEX*****************************************************************//  void quickSort(int arr[], int low, int high){  if (low < high){  int pi = partition(arr, low, high);  quickSort(arr, low, pi - 1);  quickSort(arr, pi + 1, high);  }  }  //PRINT  ARRAY****************************************************************************** *************************************//  void printArray(int arr[], int size){  11   
  • 13. for (int i=0; i <=size; i++)  printf("%d ", arr[i]);  printf("n");  }  // MAIN  METHOD**************************************************************************** **************************************//  int main(){  int arr[]=  {195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165,  192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143,  155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104,  130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179  ,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187  ,166 ,156 ,109 ,167 ,157};  //int arr[] = {10, 7, 8, 9, 1, 5};  //int arr[] = {38,27,43,3,9,82,10};  //int arr[] ={10, 80, 30, 90, 40, 50, 70};  int arr_size = sizeof(arr)/sizeof(arr[0]);  printf("GIVEN ARRAY WHICH HAVE TO BE SORTED: nn");  printArray(arr, arr_size);  //QUICK SORT  METHOD**************************************************************************** *********************************//  quickSort(arr, 0, arr_size-1);  printf("QUICK SORTED ARRAY IS : nn");  printArray(arr, arr_size);  12   
  • 14. //PRINT THE NUMBER OF COMPARISONS AND  SWAPS****************************************************************************** ********//  printf("nnNUMBER OF COMPARISONS IS: %dnn", comparsioncounter);  printf("NUMBER OF SWAP IS : %dn", swapcounter);  return 0;  }      OUTPUT:  Fig :3- Quick sort in ascending order          13   
  • 15.         CODE FOR [101-200] SORT IN ASCENDING ORDER  #include <stdio.h>  //PRINT  ARRAY****************************************************************************** ************************************//  void printArray(int arr[], int size){  int i;  for (i=0; i < size; i++)  printf("%d ", arr[i]);  printf("n");  }  //MAIN  METHOD**************************************************************************** ***************************************//  int main(){  int arr[100]=  {195,134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165,  192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143,  155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104,  130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179  ,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187  ,166 ,156 ,109 ,167 ,157};  14   
  • 16. int temp=0;  int arr_size = sizeof(arr)/sizeof(arr[0]);  //PRINT THE GIVEN ARRAY  printf("GIVEN ARRAY WHICH HAVE TO BE SORT IS: n");  printArray(arr, arr_size);  // CODE FOR ASCENDING ORDER OF ARRAY ELEMENT  for (int i = 0; i < arr_size; i++){  for (int j = i+1; j < arr_size; j++){  if (arr[j] < arr[i]){  int tmp = arr[i]; //Using temporary variable for storing    arr[i] = arr[j]; //replacing value  arr[j] = tmp;  }  }  }  //PRINT ARRAY IN ASCENDING  ORDER****************************************************************************** *******************//  printf("nALREADY IN ASCENDING SORT OF THAT ARRAY:n");  for(int i=0; i< arr_size; i++){  printf("%d ",arr[i]);  }  return 0;  }  15   
  • 17.       OUTPUT:  Fig :4- [101-200] array in ascending order        CODE FOR [200-101] SORT IN DESCENDING ORDER  #include <stdio.h>  //PRINT  ARRAY****************************************************************************** *************************************//  16   
  • 18. void printArray(int arr[], int size){  int i;  for (i=0; i < size; i++)  printf("%d ", arr[i]);  printf("n");  }  //MAIN  METHOD**************************************************************************** ***************************************//  int main(){  int arr[100]=  {195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165,  192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143,  155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104,  130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179  ,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187  ,166 ,156 ,109 ,167 ,157};  int temp=0;  int arr_size = sizeof(arr)/sizeof(arr[0]);  //PRINT THE GIVEN  ARRAY****************************************************************************** ***************************//  printf("GIVEN ARRAY WHICH HAVE TO BE SORT IS: nn");  printArray(arr, arr_size);  // CODE FOR ASCENDING ORDER OF ARRAY ELEMENT  for (int i = 0; i < arr_size; i++){  for (int j = i+1; j < arr_size; j++){  17   
  • 19. if (arr[j] > arr[i]){  int tmp = arr[i]; //Using temporary variable for storing  last value  arr[i] = arr[j]; //replacing value  arr[j] = tmp;  }  }  }  //PRINT ARRAY IN DESCENDING  ORDER****************************************************************************** *****************//  printf("nALREADY IN DESCENDING SORT OF THAT ARRAY:n");  printf("n");  for(int i=0; i< arr_size; i++){  printf("%d ",arr[i]);  }  printf("n");  return 0;  }            18   
  • 20. OUTPUT:  Fig :5- [200-101] like descending order      CODE FOR [101-200] SORT IN RANDOM ORDER  #include <stdio.h>  #include <stdlib.h>  #include <time.h>  //101-200 SORT USING THE RANDOM FUNCTION  // FUNCTION TO SWAP THE INTEGER ARRAY ELEMENT to swap to integers  //METHOD FOR  SWAP******************************************************************************* ********************************//  19   
  • 21. void swap (int *a, int *b){  int temp = *a;  *a = *b;  *b = temp;  }  // PRINT ARRAY  FUNCTIOKN************************************************************************* *******************************//  void printArray (int arr[], int size){  for (int i = 0; i < size; i++)  printf("%d ", arr[i]);  printf("n");  }  // A FUNCTION TO GENERATE A RANDOM  NUMBERS*************************************************************************** ***********//  void randomize ( int arr[], int n ){  srand ( time(NULL) );  for (int i = n-1; i > 0; i--){  // PIC A RANDOM INDEX FROM 0 TO i  int j = rand() % (i+1);  // SWAP arr[i] WITH THE ELEMENT AT RANDOM INDEXS  swap(&arr[i], &arr[j]);  }  }  20   
  • 22. //MAIN  METHOD**************************************************************************** ***************************************//  int main(){  int arr[100] =  {195, 134, 144, 141, 145, 197, 177, 101, 196, 146, 175, 173, 154, 171, 111, 136, 115, 162, 165,  192,131, 142, 120, 185, 102, 181, 107, 198, 106, 176, 121 ,178 ,119, 128 ,193 ,127 ,123 ,143,  155 ,186,191, 122 ,132 ,158, 129 ,183, 163, 180 ,103 ,188, 150 ,151, 172 ,118 ,174 ,170, 104,  130, 116, 117,112 ,139 ,194, 147 ,153, 164, 169 ,199, 148 ,138 ,200 ,190 ,126 ,152 ,161 ,179  ,149 ,137 ,133 ,110,159 ,113, 140 ,160 ,105 ,184 ,182 ,135 ,114 ,125 ,168 ,189 ,124 ,108 ,187  ,166 ,156 ,109 ,167 ,157};  //int i;  int arr_size = sizeof(arr)/sizeof(arr[0]);  printf("GIVEN ARRAY WHICH HAVE TO BE REARANGE WITH RANDOM: n");  printf("n");  for(int i = 0; i < arr_size; i++){  printf("%d ", arr[i]);  }  //PRINT RANDOM ARRAY  ELEMENT*************************************************************************** *************************//  printf("n");  printf("nSORTED USING RANDOM SORT IS : nn");  int n = sizeof(arr)/ sizeof(arr[0]);  randomize (arr, n);  printArray(arr, n);  printf("n");  21   
  • 23. return 0;  }      OUTPUT:  Fig :6- [101-200] array sort in random order                22   
  • 24. MATERIALS  1. Code Block IDE Tools  2. GDB/CDB debugger  3. IntelliJ IDE/Netbeans IDE  4. JDK  PROCEDURE  1. C Programming  2. C++ Programming  3. Java Programming    OUTPUT DATA REPORT FOR TOTAL COMPARISONS & SWAPS COUNT:  ALGORITHM  NO OF COMPARISONS  NO OF SWAPS  Insertion Sort      Merge Sort      Quick Sort      RESULTS  We have used C programming language for that assignment completions. Which has                        given the ultimate result for Insertion Sort, Merge Sort & Quick Sort using their algorithm                              & pseudo codes. After that we have sorted the given input array [101-200] in Ascending                              ,Descending & also Randomize options too.    23   
  • 25. CONCLUSION    1. Insert sort is more efficient than bubble sort and selection sort.In this algo we  divide the entire array into parts; the sorted array and the unsorted array.With  every iteration we have to place the first element of the unsorted array in the  correct position of the sorted array and increase the sorted list by one.  Time Complexity:  when elements are sorted there are no swaps and the correct position of the                            element in the sorted list is the current index itself.The time complexity is : O(n)  Insertion sort gets penalized if comparison or copying is slow. In other words, the                            maximum array size which is faster to sort with insertion sort compared to                          O(nlogn) algorithms gets smaller if comparison or copying of the array elements is                          slow.  Divide and Conquer Approach-  In this approach the algorithm is divide into multiple sub-problems.Each of these                        sub-problems is then solved separately and the solution of each sub-problem is                        used to solve the original problem.  Divide and conquer technique uses recursion to solve each of the sub-problem.                  24   
  • 26. Fig : Insertion Sort Time Complexity    2. Merge sort uses the divide and conquer approach.It is one of the most efficient                            algo for sorting.In this algo,we divide the list into two from the middle and keep                              dividing the list until the sub-problems has only one element list.  We then merge the list and while merging the list we sort them in the ascending                                order.  Time complexity:  We are dividing the list into no matter if the list is sorted or no.But if the array is                                      sorted,while merging the list there are no swaps merging results into an array                          itself.Thus, the best ,average and worst case time complexity is: O(nlogn)  Surprisingly fast, at least with the optimizations used in this test (ie. the sorting                            function doesn't need to allocate the secondary array each time it is called). Given                            that it is always O(nlogn), it is a very good alternative if the extra memory                              requirement is not a problem.  Array elements with fast comparisons and slow copying seem to slightly penalize                        merge sort.  25   
  • 27. Fig: Merge Sort Time Complexity    3. Quick sort uses the similar approach of divide and conquer technique  In this technique, element is selected which is the pivot element.Now the element                          which are less than the pivot are placed to the left of the array and the element                                  which are more than the pivot are placed to the right of the pivot.The index of the                                  pivot element is then returned back to the function.The same function is called to                            the sub-array left to the pivot which has all the elements less than the pivot and                                also to the right of the sub-array which has the elements more than the pivot.  After calling the function recursively,the resulting function will be a sorted array.  Time complexity:  The best case is when the elements are in a sorted manner. The best and average                                case time complexity is : O(nlogn)  The worst case time complexity is when the elements are in a reverse sorted                            manner.The time complexity is :O(n2)  In this Quick Sort,the last element in the list is taken as the pivot element.This                              Quick Sort is a bit slow as compared to other approaches of Quick Sort.  26   
  • 28.   Fig: Quick Sort Time Complexity    4. For Random sort approach,Most of the times this is going to be the approach                            since we are going to sort random number elements  Other sort,should never be employed.They take hours to sort a million                      elements.We can see that by the readings provided in the zip file of the                            assignment 5 folder.  Merge sort performs very well for this sort.It should be employed.  Also the quick sort algorithm performs very well for a million elements.All three                          approaches of quick sort are pretty fast and any of them can be                          employed.However,if one requires very good efficiency,he should use Quicksort                  pivot-median approach.        27   
  • 29.   Fig: Random Sort Time Complexity    REFERENCES  1. Class Lectures & pseudo-codes  2. Stack Overflow  3. GeeksforGeeks  4. Other Blog Sites  5. Books Help    28