Hide Index
- Understanding insertion at beginning
- Insert at beginning
- Understanding insertion at end
- Insert at end
- Understanding insertion after the given node
- Insert after the given node
- Understanding insertion before a given node
- Insert before the given node
- Understanding insertion at a given distance
- Insert at given distance
- Understanding deletion of first node
- Delete first node
- Understanding deletion of last node
- Delete last node
- Understanding deletion by given data
- Delete node with given data
- Delete nodes with given data
- Understanding deletion after a given node
- Delete node after the given node
- Understanding deletion before a given node
- Delete node before the given node
- Understanding deletion of the given node
- Delete the given node
- Understanding deletion at a given distance
- Delete node at given distance
Understanding the reorder pattern
Some linked list problems require us to reorder the nodes of the given list in place based on some conditions. In most cases, this requires first splitting the list based on the outcome of some function f1 (for example, a predicate that sends odd indexed nodes to one list and even indexed nodes to the other) and then merging back the split list together either by using another function f2 (for example, a rule that picks nodes alternately from the two lists) or simply concatenating them. These are generally medium difficulty problems that require either the split or merge technique we learned earlier or both. Many such problems may also require using other techniques, such as the reversal or fast and slow pointer technique.
The reorder pattern is a classification of problems that require reordering the nodes of a linked list in place.
Reordering nodes in a linked list is a combination of splitting and merging.
Reordering technique
Liking the course? Check our discounted plans to continue learning.