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.
defSortedInsert(head,data):temp=Node(data)ifhead==None:head=tempelse:cur=headifcur.data>=data:#insert temp to headtemp.next=curcur.prev=tempreturntempelse:#insert temp to non-head part of listwhilecur.next!=None:ifcur.data<dataandcur.next.data>=data:temp.next=cur.nextcur.next.prev=tempcur.next=temptemp.prev=curbreakelse:cur=cur.nextelse:cur.next=temptemp.prev=curreturnhead
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 →
Python Iteration: