As you know, LinkedIn is a social network, and users are connected to one another through first- or second-degree connections. In order to better understand this concept, use the following diagram as a reference:

Figure 1
Suppose that I want to find an acquaintance named Jill and connect with her. When I go to her profile, I find that she is a second-degree connection, which means that we have a mutual colleague. Let's look at how this degree is computed. To do so, we will create a connection tree:
- We start with the profile node, Dev, and add it to the connection tree:

Figure 2
- Now, I will find my colleagues and add them beneath my node. So, I add Ali and Tom beneath the Dev node:

Figure 3
- Now, for both Ali and Tom, I find their colleagues and add them beneath their nodes. So, under Ali, I add Dev, Seth, and Ram, and under...