c++ - Finding smallest value in an array most efficiently -


The array contains n values, and one of the lowest values ​​is the. How can I get the smallest value from the most efficient?

If they are ordered, then you can not do much, but look at every one who N), and when you do, you will know the minimum.


Pseudo-code:

  small = & lt; Biggest value & gt; // like element (lt; small) small = element  

was a better way to remind me: // like std :: numerical_limits for every element in the standard < Int & gt; Just start small with the first element:

  small = element [0]: for each element in the array beginning with <1 (no 0): if (element  

wrapped in the header as above.


If you can keep your orange sorted as items, it will be (1) to find it, because you can keep the youngest on the front.

It is as good as it is with arrays.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -