हिंदी

Write an algorithm to find smallest element in an Array.

Advertisements

प्रश्न

Write an algorithm to find smallest element in an Array.

संक्षेप में उत्तर
Advertisements

उत्तर

1) Initialize both first and second smallest as INT_MAX
   first = second = INT_MAX
2) Loop through all the elements.
   a) If the current element is smaller than first, then update first 
       and second. 
   b) Else if the current element is smaller than second then update 
    second
shaalaa.com
Basic Data Structures (Stack, Queue, Dequeue)
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2014-2015 (March)

APPEARS IN

Advertisements
Share
Notifications



      Forgot password?
Use app×