arrays - Algorithm balanced K-D tree with O(kn log n) -
i tried implement balanced k-d tree o(kn log n), used presorted k arrays (sorted arrays each index) o(kn log n), , median balanced tree. the problem faced median value @ level ,for example median x axis, maybe chosen again @ subsequent level, example y axis. i tried solve dividing y sorted array 2 arrays using chosen x value pivot, way wouldn't yield balanced tree. any idea how k-d balanced tree o(kn log n)? edit quoted wiki https://en.wikipedia.org/wiki/k-d_tree alternative algorithms building balanced k-d tree presort data prior building tree. maintain order of presort during tree construction , hence eliminate costly step of finding median @ each level of subdivision. 2 such algorithms build balanced k-d tree sort triangles in order improve execution time of ray tracing three-dimensional computer graphics. these algorithms presort n triangles prior building k-d tree, build tree in o(n log n) time in best case.[5][6] algorithm builds balanced k...