Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- Binary Search Tree and Doubly Linked Listhistorical
Given a binary search tree, convert it into a sorted doubly linked list. No new nodes may be created; only the pointers between existing tree nodes may be adjusted.
- Construct Binary Tree from Preorder and Inorder Traversalhistorical
Construct a binary tree from its preorder traversal and inorder traversal.
- Kth Node in a Binary Search Treehistorical
Given a binary search tree, find its kth smallest node. For example, in (5, 3, 7, 2, 4, 6, 8), the value of the third smallest node is 4.
- Binary Tree Preorder, Inorder, and Postorder Traversalhistorical
Print all nodes of a binary tree in preorder, inorder, and postorder respectively.
- Depth of a Binary Treehistorical
Given a binary tree, find its depth. A path is formed by the nodes traversed from the root to a leaf, including both the root and the leaf. The length of the longest path is the depth of the tree.
- Convert BST to Greater Treehistorical
Given the root of a binary search tree whose node values are distinct, convert it to a Greater Sum Tree so that the new value of each node equals the sum of all values in the original tree that are greater than or equal to node.val.
- Print a Binary Tree from Top to Bottomhistorical
Print every node of a binary tree from top to bottom, with nodes on the same level printed from left to right.
- Validate Binary Search Treehistorical
Given a binary tree, determine whether it is a valid binary search tree.
- Symmetric Binary Treehistorical
Implement a function to determine whether a binary tree is symmetric. A binary tree is defined as symmetric if it is identical to its mirror image.
- Flatten Binary Tree to Linked Listhistorical
Flatten a binary tree in place into a linked list whose node order follows the tree's preorder traversal.