We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Binary

Binary Tree Traversal with Strategy design pattern and open-closed principle

btree

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

bst

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 …

Designing a Binary Search Tree Validation classRead More

Converting a Binary Search Tree to a Sorted Doubly Linked List

Binary Search Tree Template

Change the left and right pointers of each node in Binary search Tree to make it a sorted doubly linked list. Method: Just do the Post order traversal and while visiting the node, Advertisements     Point the left link of visiting node to right most node in left tree.     Point the right link of …

Converting a Binary Search Tree to a Sorted Doubly Linked ListRead More

Finding nth Largest and Smallest Node in Binary Seach Tree

BST

Binary Search Tree Concept: In Binary Search Tree, Advertisements When we do the In-Order traversal, nodes will be visited in ascending order.In-Order Traversal For each Node, Traverse the left subtree Visit the node Traverse the right subtree i.e. for above BST, nodes will be visited in following order, 1 , 3 , 4 , 5 …

Finding nth Largest and Smallest Node in Binary Seach TreeRead More

C++11 Smart Pointer – Part 5: shared_ptr, Binary trees and the problem of Cyclic References

bst

Main advantage of shared_ptr is that it automatically releases the associated memory when not used any more. But if we don’t use shared_ptr carefully then this advantage can turn into a disadvantage. Let’s look how, Advertisements Suppose I have to design a binary tree and in it the node contains a pointer to left and …

C++11 Smart Pointer – Part 5: shared_ptr, Binary trees and the problem of Cyclic ReferencesRead More

Cart

Your Cart is Empty

Back To Shop