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.
publicstaticDoublyLinkedListNodesortedInsert(DoublyLinkedListNodehead,intdata){DoublyLinkedListNodedummy=head;DoublyLinkedListNodeprevious=null;DoublyLinkedListNodenode=newDoublyLinkedListNode(data);while(head!=null){if(head.data>data){// First elementif(previous!=null){previous.next=node;}node.next=head;node.prev=previous;return(node.prev==null)?node:dummy;}previous=head;head=head.next;}previous.next=node;node.prev=previous;node.next=null;returndummy;}
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 →