1. a binary search tree in c++ using a generic approach with both BFS and DFS approach working tree https://www.onlinegdb.com/edit/HkuQLdA-w code=> some properties of binary search tree-> 1. binary search tree is not always a balanced tree. 2. Inorder, traversing gives you sorted data. 3. best is o(log n) and worst is O(n). 4. left node data is always less than root data and right node data always be greater than root data. 5. red-black tree STL map is a balanced binary search tree. *******************************************************************************/ #include <stdio.h> #include<iostream> #include<queue> using namespace std; template < typename T > class Node { //can store any type of data private: //genric data or store any type of data T data; //reference of left pointer Node *left = nullptr; //reference of right pointer Node *rig...
Comments
Post a Comment