+1 Rehman . · April 4, 2015
i want to ask an algo of a problem which is : "Take an array and program it like it should print the smallest number " it should be like linear sort but dont sort it

Post a Reply


- page 2
Oldest  Newest  Rating
0 Dol Lod · April 4, 2015
That is pseudocode for getting the minimum value in an array or container. 

To be fair, I don't really get what your question is asking. I assumed it was asking for how to get the minimum value in an array. 
+1 Rehman . · April 4, 2015
didn't get your answer, sorry
0 Dol Lod · April 4, 2015
I have no idea what you are talking about sorting for. However the easiest way to do this is the following.

If the array is NULL,
      throw an exception.
Set min to be the first element in the array.
For each element in the array,
      if the element is less than min, 
            set min to the element's value
Print out min. 

Is this what you mean, I am not soring at all and this will give the minimum value of the array.

Code is now indented for clarification although apparently changes cannot be seen. As a workaround, I added braces. 
  • 1
  • 2

General Chat


Chat about anything non-computer related including, music, movies, tuna sandwiches, and more!

Bucky Roberts Administrator