gdata.io.handleScriptLoaded({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$georss":"http://www.georss.org/georss","xmlns$thr":"http://purl.org/syndication/thread/1.0","xmlns$blogger":"http://schemas.google.com/blogger/2008","id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385"},"updated":{"$t":"2023-12-09T13:35:10.032-08:00"},"category":[{"term":"Hackerrank Delete duplicate-value nodes from a sorted linked list Solution"},{"term":"Hackerrank Print the elements of a linked list solution"},{"term":"PATTERNS"},{"term":"pattern generation in c"},{"term":"c++ program"},{"term":"Hackerrank Reverse a doubly linked list solution"},{"term":"programming"},{"term":"TEXT ANALYZER"},{"term":"networks"},{"term":"triangle pattern c++"},{"term":"unipolar encoding simulation"},{"term":"Hackerrank Print in Reverse solution"},{"term":"c++"},{"term":"education"},{"term":"opps sandclock pattern"},{"term":"opps triangle pattern"},{"term":"Linked Lists in C++"},{"term":"coding"},{"term":"C++ Diamond Pattern"},{"term":"hourglass pattern c++"},{"term":"hackerrank"},{"term":"java"},{"term":"c"},{"term":"Utopian tree"},{"term":"lexical analyser"},{"term":"cpp"},{"term":"Hackerrank Insert a node into a sorted doubly linked list Solution"},{"term":"java program"},{"term":"mini project"},{"term":"c programming"},{"term":"operator precedence"}],"title":{"type":"text","$t":"GRK"},"subtitle":{"type":"html","$t":"A blog by Gokul Raj Kumar"},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://www.blogger.com/feeds/5735018943946871385/posts/default/-/Hackerrank+Insert+a+node+into+a+sorted+doubly+linked+list+Solution?alt\u003djson-in-script\u0026max-results\u003d6"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/5735018943946871385/posts/default/-/Hackerrank+Insert+a+node+into+a+sorted+doubly+linked+list+Solution?alt\u003djson-in-script\u0026max-results\u003d6"},{"rel":"alternate","type":"text/html","href":"http://blog.grkweb.com/search/label/Hackerrank%20Insert%20a%20node%20into%20a%20sorted%20doubly%20linked%20list%20Solution"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"https://www.blogger.com/profile/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"generator":{"version":"7.00","uri":"https://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"1"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"6"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-1975582297260883170"},"published":{"$t":"2015-09-23T09:45:00.004-07:00"},"updated":{"$t":"2022-01-16T10:02:25.928-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Hackerrank Insert a node into a sorted doubly linked list Solution"},{"scheme":"http://www.blogger.com/atom/ns#","term":"coding"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++ program"},{"scheme":"http://www.blogger.com/atom/ns#","term":"hackerrank"}],"title":{"type":"text","$t":"Insert a node into a sorted doubly linked list Solution"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003ch2 style\u003d\"text-align: left;\"\u003e\n\u003cstrong style\u003d\"background-color: white; border: 0px; color: #39424e; font-family: \u0026quot;Whitney SSm A\u0026quot;, \u0026quot;Whitney SSm B\u0026quot;, verdana, \u0026quot;Lucida Grande\u0026quot;, sans-serif; font-size: 18px; font-stretch: inherit; line-height: 27px; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003eProblem Statement\u003c/strong\u003e\u003c/h2\u003e\nYou’re given the pointer to the head node of a sorted doubly linked list and an integer to insert into the list. Create a node and insert it into the appropriate position in the list. The head node might be NULL to indicate that the list is empty.\u003cbr /\u003e\n\u003ch2 style\u003d\"text-align: left;\"\u003e\n\u003cb\u003eSource Code:\u003c/b\u003e\u003c/h2\u003e\n\u003cpre style\u003d\"background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003e\u003ccode style\u003d\"color: black; overflow-wrap: normal; word-wrap: normal;\"\u003e Node* SortedInsert(Node *head,int data)  \n {  \n   // Complete this function  \n   // Do not write the main method.   \n   Node *temp \u003d new Node;  \n   temp-\u0026gt;data \u003d data;  \n   temp-\u0026gt;next \u003d NULL;  \n   temp-\u0026gt;prev \u003d NULL;  \n   if(head \u003d\u003d NULL){  \n     head \u003d temp;  \n   }else{  \n     Node *temp1 \u003d temp;  \n     temp-\u0026gt;next \u003d head;  \n     head \u003d temp;  \n     while(temp!\u003d NULL){  \n       temp1 \u003d temp;  \n       temp \u003d temp-\u0026gt;next;  \n       if(temp!\u003dNULL){  \n         if(temp1-\u0026gt;data\u0026gt;temp-\u0026gt;data){  \n           int tdata;  \n           tdata \u003d temp1-\u0026gt;data;  \n           temp1-\u0026gt;data \u003d temp-\u0026gt;data;  \n           temp-\u0026gt;data \u003d tdata;  \n         }  \n       }  \n     }  \n   }  \n   return head;  \n }  \n\u003c/code\u003e\u003c/pre\u003e\n\u003cbr /\u003e\u003c/div\u003e\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://blog.grkweb.com/feeds/1975582297260883170/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://blog.grkweb.com/2015/09/hackerrank-insert-node-into-sorted.html#comment-form","title":"7 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/5735018943946871385/posts/default/1975582297260883170"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/5735018943946871385/posts/default/1975582297260883170"},{"rel":"alternate","type":"text/html","href":"https://blog.grkweb.com/2015/09/hackerrank-insert-node-into-sorted.html","title":"Insert a node into a sorted doubly linked list Solution"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"https://www.blogger.com/profile/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"7"}}]}});