Showing posts with label algorithms. Show all posts
Showing posts with label algorithms. Show all posts

Friday, July 6, 2012

Strahler Number of a Binary Tree

This post is going to cover how to find a strahler number of a binary tree. We are going to start by explaining what a strahler number is, the algorithm for finding a strahler number and I will also provide a nice little program to demonstrate this. I provide no source code for the program, but I will be more than happy to assist you with any problems you might encounter writing a program for a strahler number.

1. Strahler Number - Description and Algorithm



The Strahler Number is the branching complexity of a tree. It has been introduced by hydrologists for studying the morphology of the river networks and was later used in computer science regarding some optimization problems. The Strahler number can be defined by the following recursive rule:

Recursive rule for strahler number

The notation that we use is strahler(L, r, R) - L refers to the left subtree, r is the root, and R is the right subtree. The way the algorithm works is that all leaf nodes are assigned a strahler number of 1. If a node has only one child, it is assigned the strahler number of its child. This is also defined by the recursion above which checks whether strahler(L) == strahler(R).