# Algorithms

This category contains all the posts related to Algorithms. For e.g.: Sorting, Hashing, Searching, Tree Traversals, Graph Theory etc.

## Inorder Predecessor of node in Binary Tree Using Parent Pointer

Introduction This is the seventh article in the Tree Traversals - Online Classes. This article presents ways to find out inorder predecessor of node in binary tree. As we have already read about the Inorder Successor it wont take much effort to understand the predecessor. Definition - Inorder Predecessor of node in Binary Tree If a node K is called the inorder predecessor of node N then N must be visited immediately after K in a inorder traversal of the tree. Below is a more formal definition of Inorder Predecessor: If the node has a left sub-tree, then inorder predecessor is the ...

## Inorder Successor of node in Binary Tree Using Parent Pointer

Introduction This is the sixth article in the Tree Traversals - Online Classes. This article presents ways to find out inorder successor of node in binary tree. Before we jump into the code it would be good to correctly define the meaning of the problem. Definition - Inorder Successor of node in Binary Tree If a node K is called the inorder successor of node N then K must be visited immediately after N in a inorder traversal of the tree. Below is a more formal definition of Inorder Successor: If the node has a right sub-tree, then inorder successor is the left most node of the rig...

## Tree Diameter

Introduction This is the fifth article in the Tree Traversals - Online Classes. A very interesting problem is to find the diameter of a tree. The challenge is not in coding the algorithm but in understanding the meaning of the problem. We will try to define the problem so that visualizing the solution becomes easy. Defining the problem - Tree Diameter Few confusions about the diameter must be avoided before we start. The tree diameter is always the distance between two leaf nodes The diameter may or may not pass through the root. The diameter can also lie on one of the two sides,...