Ok I am think I am doing this right, I am finding the big theta for algorithms
I have two:
#1
int selectKth( int a[], int k, int n )
{
int minI;
int tmp;
for ( int i = 0; i < k; i++ ){
minI = i;
for ( int j = i + 1; j < n; j++ )
{
if ( a[j] < a[minI] )
{
minI = j;
}
tmp = a[i];
a[i] = a[minI];
a[minI] = tmp;
}
}
return a[k - 1];
}
#2
for ( int i = 0; i < n - 1; i++ ){
for ( int j = i + 1; j < n; j++ )
{
tmp = a[i][j];
a[i][j] = a[j][i];
a[j][i] = tmp;
}
}
Do these both have the same big theta?
I see them as having N^2.
Am I doing this right?