Question:

Programming get the biggest number?

by  |  earlier

0 LIKES UnLike

Are the an even faster way of getting the biggest number instead of the old fashion way.

Function Max(a, b)

if a>b Then Return a Endif

Return b

EndFunction

Code can be written in any langauge.

By the way, what I mean are thy anything like this ...

Max = a / b * 10

Some caculation?

 Tags:

   Report

1 ANSWERS


  1. the shell sort is the fastest technique for small sets of data.  For larger (multiple thousands) the quick sort is the fastest, but is more complex and harder to implement.

    A simple shell sort in C++ from wikipedia:

    void shell_sort(int A[], int size) {

      int i, j, increment, temp;

      increment = size / 2;



      while (increment > 0) {

        for (i = increment; i < size; i++) {

          j = i;

          temp = A[i];

          while ((j >= increment) && (A[j-increment] > temp)) {

            A[j] = A[j - increment];

            j = j - increment;

          }

          A[j] = temp;

        }



        if (increment == 2)

           increment = 1;

        else

           increment = (int) (increment / 2.2);

      }

    }

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.