mohit89mlnc
BAN USERvoid vertical_sum(Node n,int sum[],int column)
{
if(n==NULL) return ;
sum[column]+=n->v;
vertical_sum(n->l,sum,column+1);
vertical_sum(n->r,sum,column-1);
}
void vertical_init(Node root)
{
int h=height(root);
int *sum=new int[h+1];
h=pow(2,h-1)/2;
vertical_sum(root,h);
for(int i=0;i<=2*h;i++)
cout<<sum[i]<<" ";
return ;
}
the time complexity should be O(mlogn) (upper bound) where m is length of largest string in the set. In O("n"logn) first n does not make any sense.Tell me if i am wrong.
- mohit89mlnc July 11, 2011shared memory is the fastest IPC. I think there is no harm in using shared memory for multi process application if commonly used space is fixed. But if application is in hierarchical order then pipes are better than FIFOs (named pipes). But if for general case, then we can use FIFOs.
- mohit89mlnc June 29, 2011you can check malloc() manual in linux distros. if size in malloc() or calloc() call is zero then both of them may return NULL or some unique pointer value which may be further used by free().
- mohit89mlnc June 27, 2011
Is the tree given BST?
- mohit89mlnc October 25, 2011