Complete the code to insert a value into a Binary Search Tree (BST).
if (root == null) { root = new TreeNode([1]); }
We insert the given value as the new root node when the tree is empty.
Complete the code to check if a key exists in a hash map.
if (hashMap.[1](key)) { Console.WriteLine("Key found"); }
The ContainsKey method checks if the key exists in the hash map.
Fix the error in the BST search method to correctly compare keys.
if (key [1] node.Value) { return Search(node.Left, key); } else if (key [2] node.Value) { return Search(node.Right, key); } else { return node; }
In a BST, if the key is less than the node's value, search left; if greater, search right.
Fill both blanks to create a dictionary comprehension that filters keys greater than 10.
var filtered = [1].Where(kv => kv.Key [2] 10).ToDictionary(kv => kv.Key, kv => kv.Value);
We filter the hashMap for keys greater than 10 using the '>' operator.
Fill all three blanks to create a BST in-order traversal that collects values greater than 5.
var result = new List<int>();
void InOrder(TreeNode node) {
if (node == null) return;
InOrder(node.[1]);
if (node.Value [2] 5) {
result.[3](node.Value);
}
InOrder(node.Right);
}In-order traversal visits left child first, then current node. We check if value is greater than 5 and add it to the result list.
