## DFS: Connected Cell in a Grid

Consider a matrix where each cell contains either a 0 or a 1 and any cell containing a 1 is called a filled cell. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally. In the diagram below, the two colored regions show cells connected to the filled cells. Black on white are not connected. If one or more filled cells are also connected, they form a region. Note that each cell in a region is connected to at least one other cell in the r

## Matrix

The kingdom of Zion has cities connected by bidirectional roads. There is a unique path between any pair of cities. Morpheus has found out that the machines are planning to destroy the whole kingdom. If two machines can join forces, they will attack. Neo has to destroy roads connecting cities with machines in order to stop them from joining forces. There must not be any path connecting two machines. Each of the roads takes an amount of time to destroy, and only one can be worked on at a time.

## Tree: Height of a Binary Tree

The height of a binary tree is the number of edges between the tree's root and its furthest leaf. For example, the following binary tree is of height 2: Function Description Complete the getHeight or height function in the editor. It must return the height of a binary tree as an integer. getHeight or height has the following parameter(s): root: a reference to the root of a binary tree. Note -The Height of binary tree with single node is taken as zero. Input Format The first

## Binary Search Tree : Lowest Common Ancestor

You are given pointer to the root of the binary search tree and two values v1 and v2. You need to return the lowest common ancestor (LCA) of v1 and v2 in the binary search tree. Function Description Complete the function lca in the editor below. It should return a pointer to the lowest common ancestor node of the two values given. lca has the following parameters: - root: a pointer to the root node of a binary search tree - v1: a node.data value - v2: a node.data value Input For

## Trees: Is This a Binary Search Tree?

For the purposes of this challenge, we define a binary search tree to be a binary tree with the following properties: The data value of every node in a node's left subtree is less than the data value of that node. The data value of every node in a node's right subtree is greater than the data value of that node. The data value of every node is distinct. For example, the image on the left below is a valid BST. The one on the right fails on several counts: - All of the numbers on the right