'Splitting an array in list for two parts in C?
I have a linked - list that contains an array. I need to implement a quicksort algorithm [with pivot] which splits the array into two parts:
The first is a left-mini array which contains all the elements from the beginning of the original array to the middle, and the second one is a right-mini array that contains all the elements from the end of the original array to the middle
My question is, how can I split an array from a list?
Do I have to make two copies of the original array and do memory allocation in order to make two new arrays? Is there a more simple way to do that?
Here's my code so far: (the part that implementing the quicksort function)
list* support_array;
support_array = (list*)malloc(sizeof(list));
support_array = (*lst);
while (support_array != NULL)
{
i++;
support_array = support_array->next;
}
list* leftarray;
leftarray = (list*)malloc(sizeof(list));
list* rightarray;
rightarray = (list*)malloc(sizeof(list));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
