You are viewing a single comment's thread. Return to all comments →
What do you think of this:
Node* makeNode(int data){ Node* newNode = (Node*) malloc(sizeof(Node)); newNode->data = data; newNode->next = 0; newNode->prev = 0; return newNode; } Node* SortedInsert(Node *head,int data){ if (!head) { Node* newNode = makeNode(data); return newNode; } if (data < head->data){ Node* newNode = makeNode(data); newNode->next = head; head->prev = newNode; return newNode; } else{ head->next = SortedInsert(head->next, data); head->next->prev = head; return head; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Inserting a Node Into a Sorted Doubly Linked List
You are viewing a single comment's thread. Return to all comments →
What do you think of this: