BABA
BAN USERI think the following algorithm can do it all :
1)This method would give left edge of the frame.
Method1(root,arr)
{
if(root)
{
arr.append(root)
Method1(root->left , arr)
}
else
{
return arr
}
}
2)This method will generate right edge og the frame.
Method2(root,arr)
{
if(root)
{
arr.append(root)
Method2(root->right , arr)
}
else
{
return arr
}
}
3) genrate_frame(root)
{
ARRAY_TYPE arr_left[],arr_right[],arr_inorder[];
Method1(root,arr_left);
Method2(root->right,arr_right);
Inorder(root,arr_inorder);//This function returns inorder traversal of the tree.
for elem in arr_inorder:
{
if(elem->left!=NULL && elem->right!=NULL)
continue;
if(elem in arr_left)
continue;
if(elem in arr_right)
continue;
filter.append(elem)
}
print arr_left
print filter
print reverse(arr_right)
}
Repjimmybdepuy, Front-end Software Engineer at Arista Networks
Hi, I am Jimmy from los Angeles. I am a painter. I have Knowledge of different types and shades of ...
messenger ant send the keys
- BABA July 07, 2012