MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / findMedian

Function findMedian

CPP/arrays/KthSmallest.cpp:29–32  ·  view source on GitHub ↗

A simple function to find median of arr[]

Source from the content-addressed store, hash-verified

27
28// A simple function to find median of arr[]
29int findMedian(int arr[], int n) {
30 sort(arr, arr + n);
31 return arr[n / 2];
32}
33
34// Returns kth smallest element in arr[] in worst case linear time
35int kthSmallest(int arr[], int l, int r, int k) {

Callers 1

kthSmallestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected