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.
Your code wont work if the new node's data is less than the head node's data. For that you have to add an if-else loop to your code with your code in the else part with the if part as :
(ps. i created a new node at the start of the method , so you can change your code accordingly or create seperate node for this case)
Inserting a Node Into a Sorted Doubly Linked List
You are viewing a single comment's thread. Return to all comments →
Your code wont work if the new node's data is less than the head node's data. For that you have to add an if-else loop to your code with your code in the else part with the if part as : (ps. i created a new node at the start of the method , so you can change your code accordingly or create seperate node for this case)