|
Given a binary tree, CommonParent return the closest comment parent of the given nodes.
|
|
Given a binary tree, the method examines the tree to determine if it meets the requirement to be a binary search tree. To be a binary search tree, for every node, all of the nodes in its left tree must be less than or equal to the node, and all of the nodes in its right subtree must be greater than the node.
|
|
SameTree returns true if they are identical i.e. the are made of nodes with the same values arranged in the same way. Structural equivalence is when the the two trees are arranged in the same way but the values on the node may differ.
|
|
MirrorTree - Change a tree so that the roles of the left and right references are swapped at every node.
DoubleTree - for each node in a binary search tree, create a new duplicate node, and insert the duplicate as the left child of the original node. The resulting tree should still be a binary search tree.
|
|
Given a binary tree, PrintPaths print out all of its root-to-leaf paths such that adding up all the values along the path equals the given sum.
|
|
root-to-leaf path is a sequence of nodes in a tree starting with the root node and proceeding to a leaf. HasPathSum, given a binary tree and a sum, returns true if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Returns false if no such path can be found.
|
|
Size of the tree is the number of nodes in the tree. Depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Depth of an empty tree is 0.
|
|
A level-order traversal is to visit the root, then visit all nodes "1 level away" (depth 2) from the root (left to right), then all nodes "2 levels away" (depth 3) from the root, etc. A zig-zag traversal is to visit the root, then visit all nodes "1 level away" (depth 2) from the root (left to right), then all nodes "2 levels away" (depth 3) from the root (right to left), then all nodes "3 levels away" (depth 4) from the root (left to right), etc. The difference between the level-order and zig-zag order is the level-order always prints from left to right but for zig-zag the sequence alternates i.e. left to right, right to left, left to right ...
|
|
Binary Search Tree - Insertion and LookUp
|
rotateleft( char* str, int n) rotates the string str n times to the left.
rotateleft("abcdefgh",4) returns "efghabcd" and
rotateright("abcdefgh",4) returns "hgfeabcd".
|
strpstr(char* str, char* pattern)checks if the string str matches the pattern . '%' is a special character and matches one or more characters.
|
|
strcmp(char* dest, char* src) compares dest and src strings and returns less than 0 (dest is less than src), 0 (dest is equal to src) or greater than 0 (dest is greater than src). stricmp is exactly the same as strcmp except it is case insensitive.
|