Question: Algorithm Analysis ( 1 5 points ) ALGORITHM Fun ( a [ ] , int s , int e ) { int m = s

Algorithm Analysis (15 points)
ALGORITHM Fun (a[], int s, int e)
{
int m = s ;
for j = s+1 to e
if (a[ j ]< a[m]) m = j ;
return m;
}
ALGORITHM Process (a[0..n1], int n )
{
for i =0 to n2{
m = Fun (a , i , n1) ;
t = a[i ]; a[ i ]= a[m]; a[m]= t; }
}
1. What are the objectives of these two functions?
2. Find the number of array element comparisons T(n) done by a call of Fun (a, s, e), and
by a call of Process(a, n) as a function of n.
3. What are the corresponding Big-O complexities in terms of n?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!