Category : Data structure

Introduction to Binary Tree Basic structure: function TreeNode(x) { this.val = x; this.left = null; this.right = null; } Definition of traversal of binary tree’s pre-order, mid-order and post-order; Preorder traversal: for any subtree, first access heel, then traverse its left subtree, and finally traverse its right subtree; Mid-order traversal: for any subtree, first traverse ..

Read more

Introduction to Binary Tree Basic structure: function TreeNode(x) { this.val = x; this.left = null; this.right = null; } Definition of traversal of binary tree’s pre-order, mid-order and post-order; Preorder traversal: for any subtree, first access heel, then traverse its left subtree, and finally traverse its right subtree; Mid-order traversal: for any subtree, first traverse ..

Read more