What’s happening everyone? This is the latest addition to my brand new series Graph Theory: Go Hero where we discuss about graphs and related algorithms, in depth. Check it out for a quick overview. Here we’re going have a light introduction to tree which is a kind of graph. So, here we go.

What is a tree?

Image for post

We have a couple of graphs above, can you spot the odd one out?

Correct, the forth one stands out of the group. But why?

Image for post

Because a tree is an undirected graph with no cycles. The key thing to remember is trees aren’t allowed to have cycles in it. You could find one that broke the rule, right? Excellent job.

However, there’s another simple method which we can use to see whether the given graph is a tree or not. All trees have **N - 1 edges, **where N is the number of nodes.

Image for post

Three of our graphs meet the rule, right? But the last one doesn’t.

Trees out in the wild

Let’s see a couple of occasions where we encounter the applications of trees.

  • File Structure

A computer file system contains directories, subdirectories and files and it’s inherently a tree.

Image for post

  • Corporate Hierarchy

The term corporate hierarchy refers to the arrangement and organization of individuals within a corporation according to power, status, and job function. It delineates authority and responsibility, designating leadership over employees, departments, divisions, and other executives depending on their place within the strata. A complete corporate would have a tree structure.

Image for post

  • Evaluating Mathematical Expressions

Tress could be used to decompose mathematical expressions and source code into an abstract format so that they are evaluated in a formal way. Below is an expression and it’s corresponding tree representation.

(a * b) + (c - d)

Image for post

  • Web Document Object Model (DOM)

Every web page we visit is made of certain tags such as ,

, etc. DOM is an interface that treats and XML or HTML document as a tree structure wherein each node is an object representing a part of the document. One such a tree is given below.</p>

#programming #computer-science #graph-theory #deep learning #deep learning

Graph Theory | Introduction to Trees
1.55 GEEK