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
/* 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started