Category: Binary Tree
Binary Tree Traversal with Strategy design pattern and open-closed principle
Many time we need to perform certain tasks on Binary trees. These tasks can be, Counting nodes that satisfy some criteria. Displaying all nodes in particular pattern like, printing expression from expression tree. Creating mirror image of tree. etc. [showads ad=inside_post] To perform these tasks we follow a pattern i.e. traverse the tree and perform …
Binary Tree Traversal with Strategy design pattern and open-closed principleRead More
Designing a Binary Search Tree Validation class
Many times we need to validate a Binary Search tree i.e. verifying its properties, Left subtree of each node contains the nodes with value less than the node’s value. Right subtree of each node contains the nodes with value greater than the node’s value. Moreover, left and right subtree of each node must be a …
Finding paths in a Binary Tree
Many times we need to search for some specific paths in a binary tree from top to bottom. Lets design a code to find out all paths in a binary tee. Binary Search Tree For above binary tree, top to bottom paths are as follows, Advertisements 5 —> 3 3 —> 1 Frequently Asked: Designing …