I am implementing a version of merge sort in c. For the first step I have to split the array into sub-arrays.
Is it bad practice to simply do this by having two pointers, one pointing to the start of the original array and the second pointing to the middle?
Or should I malloc 2 new memory slots, copy the appropriate values here and then keep a pointer to this space?
I don’t think it’s bad practice if you know what you’re doing. In some cases, you sacrifice readability for efficiency. It’s probably more clear if you’d just create two more arrays, but if you have a firm grasp on arrays and pointers, why allocate extra memory?