You are viewing a single comment's thread. Return to all comments →
please help me my code is not working
Node* SortedInsert(Node *head,int data) { if(head==NULL) { head->data=data; return head; } if(head->next==NULL) { Node *TempNode = (Node*)malloc(sizeof(Node)); TempNode->data=data; TempNode->prev=head; head->next=TempNode; return head; } else { Node* Current=head; Node* previous=NULL; while(Current->data<data&&Current!=NULL) { previous=Current; Current = Current->next; } Node *TempNode = (Node*)malloc(sizeof(Node)); Node* Next=Current; TempNode->data=data; TempNode->prev=previous; TempNode->next=Next; previous->next=TempNode; if(Next != NULL){ Next->prev = TempNode; } } 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 →
please help me my code is not working