I am trying to answer the following questions, but Im really not sure if the matrix is a binary search tree or a binary tree. Is there any way to say?
Find the least common ancestor between the two nodes in the binary search tree. The least common ancestor is the farthest node from the root, which is the ancestor of both nodes. For example, the root is the common ancestor of all nodes in the tree, but if both nodes are descendants of the root left child, then this left child may be the lowest common ancestor. You can assume that both nodes are in the tree, and the tree itself adheres to all BST properties. The function definition should look like question4 (T, r, n1, n2), where T is a tree represented as a matrix, where the index of the list is an integer stored in this node, and 1 represents a child node, r is a non-negative integer representing the root, and n1 and n2 are non-negative integers representing two nodes in a specific order. For example, one test case might be
question4([[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0]], 3, 1, 4)