From 612d36f201c5b7b6ae71297b8f8643c3b7669894 Mon Sep 17 00:00:00 2001 From: Yash Aggarwal <72155128+yashaggarwal03@users.noreply.github.com> Date: Fri, 2 Oct 2020 22:48:35 +0530 Subject: [PATCH 1/2] Added some useful comments for easy understanding --- Array/InsertionSort.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Array/InsertionSort.cpp b/Array/InsertionSort.cpp index 991a60f..6fe8b3b 100644 --- a/Array/InsertionSort.cpp +++ b/Array/InsertionSort.cpp @@ -1,14 +1,17 @@ //Insertion sort void insertionSort(int a[], int n) { + //Nested looping is required + //while loop inside for loop int key, i, j; - for(i = 1 ; i < n ; i++) + for(i = 1 ; i < n ; i++) { key = a[i]; j = i - 1; while(j >= 0 && a[j] > key) { + //here insertion is taking place a[j + 1] = a[j]; j--; } From ce0b4db02755a2eacb596f36bfaa0742102c9964 Mon Sep 17 00:00:00 2001 From: Yash Aggarwal <72155128+yashaggarwal03@users.noreply.github.com> Date: Wed, 7 Oct 2020 22:26:58 +0530 Subject: [PATCH 2/2] Added a header file --- Array/MaxSumSubArraySizek.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Array/MaxSumSubArraySizek.cpp b/Array/MaxSumSubArraySizek.cpp index ffa635c..f008cff 100644 --- a/Array/MaxSumSubArraySizek.cpp +++ b/Array/MaxSumSubArraySizek.cpp @@ -1,3 +1,4 @@ + #include // It includes all necessary header files // Max sum subarray of size k // Time : O(n) //Space : O(1)