kth smallest element
Lesson 10 of 11 in Coddy's Bubble Sort course.
Challenge
EasyCreate a function named <strong>kth_smallest</strong> that receives an array of distinct elements, length of the array (n) and an integer k (k<=n). Return the kth smallest element of the array.
Sample Input: arr=[2,4,6,1,5,7,8], n=7, k=3
3rd smallest element is 4.
Output: 4
Try it yourself
#include <stdio.h>
#include <stdlib.h>
int kth_smallest(int* arr, int arr_size, int n, int k) {
// Write code here
return 0;
}
All lessons in Bubble Sort
1Basics of Bubble Sort
IntroductionWorking of the Bubble SortSwap adjacent elementsBubble Sort Algorithm