I am new to algorithmic programming especially in C++.
I would just like to know the basic approach (with example) to implementing in-place merge sort using linked lists. There are a few conditions/requirements:
1) The data in the nodes cannot be changed, only the pointers can be altered.
2) The Mergesort(Node* &head, int elements) function takes 2 parameters, a reference to the head pointer of the node (&head) and the number of elements in the linked list (elements).
3) Recursive merge sort is preferred.
If someone can at least show me how to approach it with a psuedocode, I would greatly appreciate it.
Thank you.
void Mergesort(Node* &head, int elements) {
}
void Merge(Node* &head1, int elements1, Node* head2, int elements2) {
}
Aucun commentaire:
Enregistrer un commentaire