Using the characters on a telephone dial, give all the permutation of strings for given digits.
Anonymous
Tree in order traversal, return the next node.ie, if the search node is found, return the next in order traversal node public class BinarySearchTree { public class TreeNode { public int value; public TreeNode left; public TreeNode right; }; static public TreeNode FindNextNodeInOrderTraversal(TreeNode root, int value) { TreeNode prev_node = null; return FindNextNodeInOrderTraversal(root, value, ref prev_node); } static public TreeNode FindNextNodeInOrderTraversal(TreeNode root, int value, ref TreeNode prev_node) { if (root == null) return null; var return_value = FindNextNodeInOrderTraversal(root.left, value, ref prev_node); if (return_value != null) return return_value; if (prev_node != null && prev_node.value == value) return root; else prev_node = root; return FindNextNodeInOrderTraversal(root.right, value, ref prev_node); } static public ArrayList InOrderTraversal(TreeNode root, ArrayList array_list = null) { if (root == null) return null; if (array_list == null) array_list = new ArrayList(); InOrderTraversal(root.left, array_list); array_list.Add(root.value); InOrderTraversal(root.right, array_list); return array_list; } }
Check out your Company Bowl for anonymous work chats.