Find the 2nd largest element in an array with minimum number of comparisons

后端 未结 24 1341
清酒与你
清酒与你 2020-11-28 01:03

For an array of size N, what is the number of comparisons required?

24条回答
  •  醉酒成梦
    2020-11-28 01:22

    Suppose provided array is inPutArray = [1,2,5,8,7,3] expected O/P -> 7 (second largest)

     take temp array 
          temp = [0,0], int dummmy=0;
        for (no in inPutArray) {
        if(temp[1]

提交回复
热议问题