From fc3a6408dc8e11eed75cdae16c982d6ae28cee5f Mon Sep 17 00:00:00 2001 From: Abhishek Nath Tiwari <110283974+abhint1@users.noreply.github.com> Date: Sun, 9 Oct 2022 15:57:03 +0530 Subject: [PATCH] K'th smallest element in array --- K,th smallest element in array | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 K,th smallest element in array diff --git a/K,th smallest element in array b/K,th smallest element in array new file mode 100644 index 0000000..05d5e5a --- /dev/null +++ b/K,th smallest element in array @@ -0,0 +1,11 @@ +def kthSmallest(arr, N, K): #arr=Array N=len(array) K=Kth element in array + arr.sort() + return arr[K-1] +if __name__ == '__main__': + arr = [12, 3, 5, 7, 19] + N = len(arr) + K = 2 + + # Function call + print("K'th smallest element is", + kthSmallest(arr, N, K))