kunal-kushwaha / DSA-Bootcamp-Java

This repository consists of the code samples, assignments, and notes for the Java data structures & algorithms + interview preparation bootcamp of WeMakeDevs.
https://www.youtube.com/playlist?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ
17.25k stars 11.08k forks source link

changed bubble sort loop condition #995

Open servesh-chaturvedi opened 1 year ago

servesh-chaturvedi commented 1 year ago

The previous loop was iterating one more time than it needed to. N - 1 elements implies that iterator i should go only upto index of second last element, which is arr.length - 1