Q.Calculate complexity of following code. Also explain best case, average case and worst-case complexity of code.
void sort(){ inti, k, cnt; for (i = 1; i < n;=""> { k = arr[i]; cnt = i - 1; do { arr[cnt + 1] = arr[cnt]; cnt = cnt - 1; } while (cnt>= 0 &&arr[cnt] > k); arr[cnt + 1] = k; } }
Attaching the image below too.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here