Find a point such that sum of the Manhattan distances is minimized | Function to print the required points which minimizes the sum of Manhattan distances ; Sorting points in all k dimension ; Output the required k points ; Driver code ; function call to print required points
< ? php function minDistance ( $ n , $ k , & $ point ) { for ( $ i = 0 ; $ i < $ k ; ++ $ i ) sort ( $ point [ $ i ] ) ; for ( $ i = 0 ; $ i < $ k ; ++ $ i ) echo $ point [ $ i ] [ ( ceil ( ( double ) $ n / 2 ) - 1 ) ] . " ▁ " ; } $ n = 4 ; $ k = 4 ; $ point = array ( array ( 1 , 5 , 2 , 4 ) , array ( 6 , 2 , 0 , 6 ) , array ( 9 , 5 , 1 , 3 ) , array ( 6 , 7 , 5 , 9 ) ) ; minDistance ( $ n , $ k , $ point ) ; ? >