IT Placement Papers Programming DataStructure
This category contains DataStructure Interview Questions and Answers |
Insert a node a sorted linked list
|
|
|
|
|
void sortedInsert(Node * head, Node* newNode) { Node *current = head; // traverse the list until you find item bigger the new node value while (current!= NULL && current->data < newNode->data) { current = current->next); } // // insert the new node before the big item // newNode->next = current->next; current = newNode; }
Only registered users can write comments. Please login or register.
|