diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..05054c5 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/C/linearSort.c b/C/linearSort.c index cdc3e9c..ca08004 100644 --- a/C/linearSort.c +++ b/C/linearSort.c @@ -14,7 +14,7 @@ for(e=0;e<=size-1;e++) scanf("%d",&i); array[e]=i; } -linearSort(arary,0,size-1); +linearSort(array,0,size-1); printf("Sorted array:\n"); for(e=0;e<=size-1;e++) printf("%d\n",array[e]); free(array); diff --git a/CPP/insertionSort.cpp b/CPP/insertionSort.cpp index 32f706f..974e1cd 100644 --- a/CPP/insertionSort.cpp +++ b/CPP/insertionSort.cpp @@ -12,10 +12,10 @@ void insertionSort(int array[], int n) /* Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current position */ - while (j >= 0 && array[j] > key) + while (j >= 0 && array[j] > key) { array[j + 1] = array[j]; - j = j - 1; + j--; } array[j + 1] = key; } @@ -26,14 +26,14 @@ int main() int size=0; cout<<"Enter no. of elements: "; cin>>size; - int *array = new int[size]; + int array[size]; + cout<<"Enter elements of array:"<>array[i]; + insertionSort(array, size); cout<<"Sorted array:"<