newbie here. Even newer to recursion. I'm writing a function for my C++ program, and as you'll be able to tell, I'm a bit clueless when it comes to recursive algorithms. I'd appreciate it greatly if someone could fix my function so I can get it working and perhaps have a better idea how to handle recursion afterward.

My function takes a two-dimensional square array of booleans, and integer i, and an integer array\_size as parameters. The function returns a boolean value.

The array is an adjacency matrix that I use to represent a set of conditionals. For example, if the value at [0][3] is true, then 0 -> 3 (if 0, then 3). If [3][7] is true, then 3 -> 7 (if 3, then 7). By the transitive property, 0 -> 7 (if 0, then 7).

The integer i is a particular element in the set of conditionals. The function will return true if this element is transitively connected to the last element in the array. The last element in the array is the integer (array\_size - 1), 

The integer array\_size is the size of each dimension of the square array. If array\_size is 20, then the array is 20x20.

The idea of this function is to determine if there is any logical "path" from the first integer element to the last integer element by the transitive property. When the path exists, the function returns true, otherwise, it returns false. The recursive call should allow it to traverse all possible paths, returning true once it finally reaches the last element and false if all paths fail.

For example, if i = 0 and array\_size = 10, then the function will return whether or not 0 -> 9 is valid according to the conditionals provided by the matrix and the transitive property.

This is my code so far:

```
bool checkTransitivity(bool **relations, int i, int array_size){
bool isTransitive = false;

if (i == array_size - 1)
{
    isTransitive = true;
}
else
{
    for (int j = i; j < array_size; j++){
        if (relations[i][j])
        {
            isTransitive = checkTransitivity(relations, j, array_size);
        }
    }
}

return isTransitive;

```

Currently, the function returns true for all input.

Any help at all is appreciated. Thanks in advance!