dsa2 min read
Flatten Binary Tree to Linked List — Morris Traversal
Flatten a binary tree in-place into a linked list following pre-order using the Morris traversal approach.
Read →
webcoderspeed.com
1276 articles
Flatten a binary tree in-place into a linked list following pre-order using the Morris traversal approach.
Convert a sorted linked list to a height-balanced BST by repeatedly finding the middle node as root.
Reverse every k nodes of a linked list recursively: check k nodes exist, reverse them, recurse on the rest.
Merge k sorted linked lists into one sorted list using a min-heap for O(n log k) time complexity.
Sort a linked list in O(n log n) time and O(1) space using bottom-up merge sort with doubling sublist sizes.