Skip to main content

Posts

Showing posts from March, 2020

Level Order Tree Traversal (Level order traversal of a tree is breadth first traversal for the tree.)

https://www.geeksforgeeks.org/level-order-tree-traversal/ level order tree Traversal or breadth first traversal for the tree with full example. please note below tree is binary search tree working link=> https://stackblitz.com/edit/typescript-gvv3qk //bfs Level Order Tree Traversal //node class which holds data and left and right child if exits class   TreeNode < T > {     private  data : T ;     private  leftChild : TreeNode < T >= null ;     private  rightChild : TreeNode < T >= null ;     constructor ( _data : T )     {       this . data = _data ;     }    getData ()     {       return   this . data ;     }    setLeft ...

write a program to print all permutations of a given vector

/******************************************************************************                               Online C++ Compiler.                Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <algorithm> #include <vector> using namespace std; void displayData(vector<string> &list,int startIndex,int endIndex) {     if(startIndex==endIndex)     {           string str="";          for(int i=0;i<=endIndex;i++)          {              str+=list[i];          }       ...