Beruflich Dokumente
Kultur Dokumente
#include "BinaryTreeNode.h"
#include "queue_node_template.h"
using namespace std;
BinaryTreeNode<int>* takeInputLevelWise()
{
int rootData;
cout<<"Enter Root Data : ";
cin>>rootData;
BinaryTreeNode<int>* root = new BinaryTreeNode<int>(rootData);
queue_node_temp<BinaryTreeNode<int>*> pendingNodes;
pendingNodes.enqueue(root);
while(!pendingNodes.isEmpty())
{
BinaryTreeNode<int>* currentNode = pendingNodes.dequeue();
cout<<"Enter Left Child for "<<currentNode->data<<" : ";
int LeftChildData;
cin>>LeftChildData;
if(LeftChildData!=-1)
{
BinaryTreeNode<int>* child = new BinaryTreeNode<int>(LeftChildData);
currentNode->left = child;
pendingNodes.enqueue(child);
}
int RightChildData;
cin>>RightChildData;
if(RightChildData!=-1)
{
BinaryTreeNode<int>* child = new BinaryTreeNode<int>(RightChildData);
currentNode->right = child;
pendingNodes.enqueue(child);
}
}
return root;
}
// PreOrder
if(root == NULL)
{
return 0;
}
if(root->data == info)
{
return root;
}
else
{
leftSearch = search(root->left , info);
rightSearch = search(root->right , info);
}
if(root == NULL)
{
return 0;
}
// BETTER METHOD
//
// Time Complexity = O(n)
class DoubleInt
{
public:
int diameter;
int height;
};
output.height = 0;
return output;
}
DoubleInt leftOutput = diameterFaster(root->left);
DoubleInt rightOutput = diameterFaster(root->right);
int treeHeight = 1+ max(leftOutput.height , rightOutput.height);
return output;
}
//
int i=0;
int mid;
while(in[i] != pre[start])
{
i++;
}
mid = i;
int j=0;
while(j < i)
{
inNewLeft[j] = in[j];
j++;
}
while( j < n)
{
inNewRight[j] = in[j];
j++;
}
return root;
}
*/
int main()
{
/*
BinaryTreeNode<int>* root = takeInputLevelWise();
print(root);
cout<<endl;
return 0;
}