add a boolean function to this bubble sort to stop comparison if an array is already sorted

前端 未结 0 1435
心在旅途
心在旅途 2021-01-27 23:44

I want to add a boolean value to this method so that if I used an already sorted array, no comparisons will be made.

      int ncomp = 0;
      int nswaps = 0;
           


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题