This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
╔════════════════╦══════════════════════════════════════════╦══════════════════════════════════════════╗ | |
║ Logic ║ Flip Binary Tree ║ Reverse Singly Linked List ║ | |
╠════════════════╬══════════════════════════════════════════╬══════════════════════════════════════════╣ | |
║ Base Case ║ Root is empty ║ Head is empty ║ | |
║ ║ Root has no left child ║ Head has no next node ║ | |
║ Recursive Call ║ Call root.left to get the final new root ║ Call head.next to get the final new head ║ | |
║ Current Call ║ Let root.left.right point to root ║ Let head.next.next point to head ║ | |
║ ║ Let root.left.left point to root.right ║ ║ | |
║ ║ Let root.left point to NULL ║ Let head.next point to NULL ║ | |
║ ║ Let root.right point to NULL ║ |