Thank you for your helpful answerIts necessary for you to pa

Thank you for your helpful answer!(It\'s necessary for you to pay attention to the given information)

Consider a problem of finding the k-th smallest element from vector A. Complete the following function. float kthSmallest (const vector& A, int k) {

Solution

#include<iostream>

using namespace std;

int smallnumber(int a[], int number, int i)

{

sort(a, a+number);

return a[i-1];

}

int main()

{

    int a= {12, 3, 5, 7, 19};

    int number = sizeof(a)/sizeof(a[0]), i = 2;

    cout << \"i\'th smallest element is \" << Smallnumber(a, number, i);

    return 0;

}

#include<iostream>

using namespace std;

int smallnumber(int a[], int number, int i)

{

sort(a, a+number);

return a[i-1];

}

int main()

{

    int a= {12, 3, 5, 7, 19};

    int number = sizeof(a)/sizeof(a[0]), i = 2;

    cout << \"i\'th smallest element is \" << Smallnumber(a, number, i);

    return 0;

}

Thank you for your helpful answer!(It\'s necessary for you to pay attention to the given information) Consider a problem of finding the k-th smallest element fr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site