Heres a DLL node definition The next of the last node will b
Here\'s a DLL node definition:
The next of the last node will be null, and the prev of the first node will be null.
With the same DLLNode definition as in the previous problem, implement a method to reverse the sequence of items in a DLL. Your code should NOT create any new nodes it should simply resequence the original nodes. The method should return the front of the resulting list public static DLLNode reverse (DILNode front) COMPLETE THIS METHODSolution
Hi, Please find my code.
Please let me know in case of any issue.
public static DLLNode reverse(DLLNode front){
Node n = front, next;
while(n.next() != null){
next = n.next;
n.next = n.prev;
n.prev = next;
n = next;
}
// n is the new front.
return n;
}
