From c8f87c9f281c7d885b9b86b8956761cfe013a474 Mon Sep 17 00:00:00 2001 From: Shubhranshu Ranjan Date: Tue, 19 Nov 2024 12:14:42 +0530 Subject: [PATCH] Update insertionSort.cpp --- Lecture018 Insertion Sort/insertionSort.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lecture018 Insertion Sort/insertionSort.cpp b/Lecture018 Insertion Sort/insertionSort.cpp index 6ceeb48a..bdc140d4 100644 --- a/Lecture018 Insertion Sort/insertionSort.cpp +++ b/Lecture018 Insertion Sort/insertionSort.cpp @@ -5,8 +5,7 @@ void insertionSort(int n, vector &arr){ for(int i = 1; i=0; j--) { + for(int j = i-1; j>=0; j--) { if(arr[j] > temp) { //shift @@ -20,4 +19,4 @@ void insertionSort(int n, vector &arr){ //copy temp value arr[j+1] = temp; } -} \ No newline at end of file +}