http://ranger.uta.edu/~alex/courses/2320/homework/2320_H3.html

1 answer below »
Answered Same DayFeb 22, 2021

Answer To: http://ranger.uta.edu/~alex/courses/2320/homework/2320_H3.html

Ria answered on Mar 02 2021
146 Votes
merge_k.c
#include
#include
#include "merge_k.h" // includes list.h
void sortedInsert(struct
Node** head_ref, struct Node* new_node)
{
struct Node* current;
/* Special case for the head end */
if (*head_ref == NULL || (*head_ref)->data >= new_node->data)
{
new_node->next = *head_ref;
*head_ref = new_node;
}
else
{
/* Locate the node before the point of insertion */
current = *head_ref;
while (current->next!=NULL &&
current->next->data < new_node->data)
{
current = current->next;
}
new_node->next = current->next;
current->next = new_node;
}
}
/* Sorts linked list L in pace using insertion sort.
    Assumes L has a dummy node.
*/
void sort_list(nodePT L){
    
    // Initialize sorted linked list
struct Node *sorted = NULL;
// Traverse the given linked list and insert every
// node to sorted
struct Node *current = L;
while (current != NULL)
{
// Store next for next iteration
struct Node *next = current->next;
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here