Question: Write a Recurrence Relation for the time complexity of the following recursive selection sort algorithm, then solve it to find its time complexity. #include using

Write a Recurrence Relation for the time complexity of the following recursive selection sort algorithm, then solve it to find its time complexity.

#include using namespace std;

/* findMin function*/ int findMin (int startIndex, int A[]) { int size = (sizeof(A)/sizeof(A[0])-1); if(startIndex == size) return startIndex; int x = findMin(startIndex+1, A); if(A[x] < A[startIndex]) return x; else return startIndex; }

/* selectionSort function */ void selectionSort(int A[]) { int size = sizeof(A)/sizeof(A[0]); for(int i = 0; i < size; i++) { int smallIndex = findMin(i,A); int temp = A[i]; A[i] = A[smallIndex]; A[smallIndex] = temp; } }

int main() { int array[] = {10,5,12,20,25,2,80,12,55,70}; int size = sizeof(array)/sizeof(array[0]); /* print before the sort array*/ cout<<"Before the sort array : "; for(int i =0 ; i < size; i++) { cout<

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 Databases Questions!