We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// IN C DoublyLinkedListNode*sortedInsert(DoublyLinkedListNode*head,intdata){DoublyLinkedListNode*ptr=(structDoublyLinkedListNode*)malloc(sizeof(DoublyLinkedListNode));DoublyLinkedListNode*temp;temp=head;ptr->data=data;if(head==NULL)returnptr;if(data<head->data){ptr->next=head;head->prev=ptr;returnptr;}while(temp->next!=NULL&&temp->next->data<data){temp=temp->next;}if(temp->next==NULL){temp->next=ptr;ptr->prev=temp;ptr->next=NULL;}else{ptr->next=temp->next;ptr->prev=temp;if(temp->next!=NULL){temp->next->prev=ptr;}temp->next=ptr;}returnhead;}
Cookie support is required to access HackerRank
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 →