I have been given the task of finding the complexity of the function used to find the kth smallest integer in an unordered array of integers. Below I have displayed the function I am analysizing. I have shown the steps as I understand them. Any help in understanding this would be appreciated.
Outside loop
Initialize i, Initialize j, setting tmp = a, setting a = a[mini], setting a[mini] = tmp, return a[k-1]
Inside Loop 1
Test i<k, Increment i, update mini = i,
Inside Loop 2
Test j < n, Increment j, Test a[j]<a[mini], update mini = j
3k *4n + 6
O(k*n)