Difference between revisions of "Algorithm"

From CDOT Wiki
Jump to: navigation, search
(Created page with 'testing')
 
Line 1: Line 1:
testing
+
{{GPU610/DPS915 Index | 20123}}
 +
= Algorithm  =
 +
 
 +
 
 +
== Team Members ==
 +
# [mailto:sskrishnamoo@learn.senecac.on.ca?subject=DPS915 sskrishnamoo]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
==== Profile ====
 +
These results were taken with an execution of 300000000 numbers of arrays
 +
<pre>
 +
Flat profile:
 +
 
 +
Each sample counts as 0.01 seconds.
 +
  %  cumulative  self              self    total         
 +
time  seconds  seconds    calls  Ts/call  Ts/call  name 
 +
100.00    68.72    68.72                            quickSort(long*, long, long)
 +
  0.00    68.72    0.00        1    0.00    0.00  _GLOBAL__sub_I_A
 +
 
 +
</pre>
 +
 
 +
==== Code Snippet ====
 +
<pre>
 +
void quickSort(long arr[], long left, long right) {
 +
      long i = left, j = right;
 +
      long tmp;
 +
      long pivot = arr[(left + right) / 2];
 +
 
 +
      while (i <= j) {
 +
            while (arr[i] < pivot)
 +
                  i++;
 +
            while (arr[j] > pivot)
 +
                  j--;
 +
            if (i <= j) {
 +
                  tmp = arr[i];
 +
                  arr[i] = arr[j];
 +
                  arr[j] = tmp;
 +
                  i++;
 +
                  j--;
 +
            }
 +
      };
 +
      if (left < j)
 +
            quickSort(arr, left, j);
 +
      if (i < right)
 +
            quickSort(arr, i, right);
 +
}
 +
 
 +
</pre>
 +
 
 +
 
 +
== Instructor's Comments ==

Revision as of 20:29, 5 October 2012


GPU610/DPS915 | Student List | Group and Project Index | Student Resources | Glossary

Algorithm

Team Members

  1. sskrishnamoo



Profile

These results were taken with an execution of 300000000 numbers of arrays

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total          
 time   seconds   seconds    calls  Ts/call  Ts/call  name   
100.00     68.72    68.72                             quickSort(long*, long, long)
  0.00     68.72     0.00        1     0.00     0.00  _GLOBAL__sub_I_A

Code Snippet

void quickSort(long arr[], long left, long right) {
       long i = left, j = right;
       long tmp;
       long pivot = arr[(left + right) / 2];

       while (i <= j) {
             while (arr[i] < pivot)
                   i++;
             while (arr[j] > pivot)
                   j--;
             if (i <= j) {
                   tmp = arr[i];
                   arr[i] = arr[j];
                   arr[j] = tmp;
                   i++;
                   j--;
             }
       };
       if (left < j)
             quickSort(arr, left, j);
       if (i < right)
             quickSort(arr, i, right);
 }


Instructor's Comments