It can be done using Queues in O(n).
--
Amitesh
On Wed, Jun 27, 2012 at 3:07 PM, hary rathor wrote:
> apply BFS
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
>
queue q;
q.enqueue(root);
while q is not empty
do
print :temp=dequeue();
if(temp->left)
enqueue(temp->left)
if(temp->right)
enqueue(temp->right);
end while;
On Wed, Jun 27, 2012 at 2:59 PM, Gobind Kumar Hembram
wrote:
> Write C code to implement level orde
int mul(int a, int b)
{
int r=0;
if (a==0|| b==0)
r=0;
else
{
for(int i=0;iwrote:
> main(a,b,m)
> 02{
> 03while (~scanf("%d%d",&a,&b))
> 04{
> 05 m=0;
> 06 while (a)
> 07 {
> 08 if (a&1)
> 09 m+=b;
> 10 a>>=1;
>
apply BFS
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this gro
Write C code to implement level order traversal of a tree.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@g
main(a,b,m)
02{
03while (~scanf("%d%d",&a,&b))
04{
05 m=0;
06 while (a)
07 {
08if (a&1)
09 m+=b;
10a>>=1;
11b<<=1;
12 }
13 printf("%d\n",m);
14}
15}
--
You received this mess
search for Ethiopian Multiplication
On Wed, Jun 27, 2012 at 9:45 AM, Gobind Kumar Hembram
wrote:
> How to multiply two numbers without using * operator?
> Hint:Use bit operators
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To pos
How to multiply two numbers without using * operator?
Hint:Use bit operators
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algog