0% completed
Prior to exiting the while loop that rearranges the LinkedList, would the last ...
Eric C
Apr 13, 2022
Prior to exiting the while loop that rearranges the LinkedList, would the last node be pointing to itself? For instance, if we had 2 -> 4 -> 6 -> 8 -> 10 -> 12 -> null, and it's rearranged to 2 -> 12 -> 4 -> 10 -> 6 -> 8 , then before the lines (Java): if (headFirstHalf != null) headFirstHalf.next = null; would the 8 node be pointing to itself? I'm having a tough time visualizing this part.
1
1
Comments
Eric C4 years ago
Also, when we reverse the second half of the LinkedList, would it resulting list be: 2 -> 4 -> 6 -> 8
Brandon Figueredo3 years ago
Getting the same result too. The last node will be pointing to else since headFirstHalf and headSecondHalf can become to same node.
Brandon Figueredo3 years ago
pointing to *itself
fellainthewagon a year ago
It is pointing to itself, but on picture a null between them which is confusing:
...->6->null<-8<-...
On this page