Re: [algogeeks] Amazon Question

2011-04-16 Thread Pratik Kathalkar
I think this solution is applicable if the binary tree is complete binary
tree, isn't it?

On Thu, Apr 14, 2011 at 12:52 AM, Harshit Gangal
harshit.gan...@gmail.comwrote:

 it 2*node and 2*node+1, if binary tree is stored in an array


 On Thu, Apr 14, 2011 at 12:36 AM, Vishakha Parvatikar 
 vishakha.parvati...@gmail.com wrote:

 Given a binary tree, write a program to find the cousin nodes of the given
 node.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Harshit Gangal
 Fourth Year Undergraduate Student
 Dept. of Computer Science
 JIIT, Noida , India

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Pratik Kathalkar
CoEP
BTech IT
8149198343

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] please explain the output

2011-04-09 Thread Pratik Kathalkar
u can see the pre-processed file using gcc -E prog_name.cand @
bottom u can see what actually the code is doing.

On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote:

 #includestdio.h

 #define f(a,b) a##b
 #define g(a) #a
 #define h(a) g(a)

 int main()
 {
 printf(%s,g(f(1,2)));
 printf(\t%s,h(f(1,2)));
 return 0;
 }



 i have run this program in gcc compiler and getting : f(1,2) 12 as
 output.
 can anyone explain the reason for getting this output?

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Pratik Kathalkar
CoEP
BTech IT
8149198343

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [brain teaser ] 1april

2011-04-06 Thread Pratik Kathalkar
if B and C have same color than A can speak the colour
else B will.




 On Fri, Apr 1, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:

 *Christmas Tree Problem *
 *
 *Four angels sat on the Christmas tree amidst other ornaments. Two had
 blue halos and two – yellow. However, none of them could see above his head.
 Angel A sat on the top branch and could see the angels B and C, who sat
 below him. Angel B, could see angel C who sat on the lower branch. And angel
 D stood at the base of the tree obscured from view by a thicket of branches,
 so no one could see him and he could not see anyone either.
 Which one of them could be the first to guess the color of his halo and
 speak it out loud for all other angels to hear?

 Update Your Answers at : Click 
 Herehttp://dailybrainteaser.blogspot.com/2011/04/1april.html?lavesh=lavesh

 Solution:
 Will be updated after 1 day

 --

 Pratik Kathalkar
CoEP
BTech IT
8149198343

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Median of Binary Tree

2011-04-06 Thread Pratik Kathalkar
What exactly the median of a Binary Tree means?

On Mon, Mar 28, 2011 at 4:38 PM, Anurag Bhatia abhati...@gmail.com wrote:

 @bittu: Can we modify the tree to store extra info?



 On Mon, Mar 28, 2011 at 4:16 PM, bittu shashank7andr...@gmail.com wrote:
  @all try to understand the question as usual we have to do it in min.
  time  space complexity ..in mean Time O(n)  space o(1) At-most
  just tell em after doing in-order traversal where u will store the
  elements either in array or in set isn'tit  it will take O(n) extra
  space why not looks fro O(1) SPACE..IF M NOT CORRECT otherwise problem
  just become finding median in array which O(1) ..correct me if m
  wrong
 
  @Anurag wher u will store inorder of tree
 
 
  Thanks
  Shashank
 
  --
  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 group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Pratik Kathalkar
CoEP

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: google mcqs

2011-01-18 Thread Pratik Kathalkar
For RAM question I guess it's answer : A

see -:
http://www.computermemoryupgrade.net/memory-influence-on-performance.html

On Mon, Jan 17, 2011 at 12:59 PM, Algoose chase harishp...@gmail.comwrote:

 Pipeline : Choice B : 165 ( this pipeline wastes 20 ns between last 2
 stages for each item )
 Scheduling : Choice B
 Ram : Choice B
 Synchronization : Choice B



 On Mon, Jan 17, 2011 at 10:01 AM, Bhavesh agrawal 
 agr.bhav...@gmail.comwrote:



 On Mon, Jan 17, 2011 at 10:00 AM, Bhavesh agrawal 
 agr.bhav...@gmail.comwrote:

 sry ,answer is a



 mistakingly written b.


 On Mon, Jan 17, 2011 at 9:58 AM, Sarma Tangirala 
 tvssarma.ome...@gmail.com wrote:

 Are larger RAMs faster?

 I am so sure about that.

 Sent from my BlackBerry
 --
 *From: * Bhavesh agrawal agr.bhav...@gmail.com
 *Sender: * algogeeks@googlegroups.com
 *Date: *Mon, 17 Jan 2011 09:36:20 +0530
 *To: *algogeeks@googlegroups.com
 *ReplyTo: * algogeeks@googlegroups.com
 *Subject: *Re: [algogeeks] Re: google mcqs

 answer is b

 Increasing the RAM of a computer typically improves performance
   because:
   a. Virtual memory increases
   b. Larger RAMs are faster
   c. Fewer segmentation faults occur
   d. Fewer page faults occur

  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Pratik Kathalkar
CoEP
BTech IT
8149198343

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Quest....

2010-12-20 Thread Pratik Kathalkar
On Sun, Dec 19, 2010 at 2:36 AM, Dave dave_and_da...@juno.com wrote:

 For 32-bit integers:

 x = ((x  16)  0X) | ((x  0X)  16);
 x = ((x   8)  0X00FF00FF) | ((x  0X00FF00FF)   8);
 x = ((x   4)  0X0F0F0F0F) | ((x  0X0F0F0F0F)   4);
 x = ((x   2)  0X) | ((x  0X)   2);
 x = ((x   1)  0X) | ((x  0X)   1);


- Can U please explain the logic of this code ?


 x is now the binary reversal of its original value.

 Dave

 On Dec 18, 1:28 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  you mean reverse or make 1 to 0 or 0 to 1 ?
 
 
 
  On Sun, Dec 19, 2010 at 12:52 AM, bittu shashank7andr...@gmail.com
 wrote:
   Write an Efficient C Program to Reverse Bits of a Number
 
   --
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
   For more options, visit this group athttp://
 groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Pratik Kathalkar
CoEP
BTech IT
8149198343

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Google Interview Question

2010-09-18 Thread pratik kathalkar
On Fri, Sep 17, 2010 at 3:36 PM, Krunal Modi krunalam...@gmail.com wrote:

 Your solutions are pretty impressive.
 Which place(country) are you from ?
 where are you studying (or done :) ) ?

 Keep it up...
 Good Wishes..
 --Krunal

 On Sep 14, 9:29 pm, Gene gene.ress...@gmail.com wrote:
  You can approach this the same way you'd do it by hand.  Build up the
  string of brackets left to right.  For each position, you have a
  decision of either ( or ) bracket except for two constraints:
  (1) if you've already decided to use n left brackets, then you can't
  use a another left bracket and
  (2) if you've already used as many right as left brackets, then you
  can't use another right one.
 
  This suggests the following alorithm. Showing what happens on the
  stack is a silly activity.
 
  #include stdio.h
 
  // Buffer for strings of ().
  char buf[1000];
 
  // Continue the printing of bracket strings.
  //   need is the number of ('s still needed in our string.
  //   open is tne number of ('s already used _without_ a matching ).
  //   tail is the buffer location to place the next ) or (.
  void cont(int need, int open, int tail)
  {
// If nothing needed or open, we're done.  Print.
if (need == 0  open == 0) {
  printf(%s\n, buf);
  return;
}
 
// If still a need for (, add a ( and continue.
if (need  0) {
  buf[tail] = '(';
  cont(need - 1, open + 1, tail + 1);
}
 
// If still an open (, add a ) and continue.
if (open  0) {
  buf[tail] = ')';
  cont(need, open - 1, tail + 1);
}
 
  }
 
  void Brackets(int n)
  {
cont(n, 0, 0);
 
  }
 
  int main(void)
  {
Brackets(3);
return 0;
 
  }
 
  On Sep 14, 10:57 am, bittu shashank7andr...@gmail.com wrote:
 
 
 
   Write a function Brackets(int n) that prints all combinations of well-
   formed brackets. For Brackets(3) the output would be ((())) (()()) (())
   () ()(()) ()()()
 
   with explaination dat is at every call what is contant of stack during
   pushing and popping

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 #includeiostream.h
#includeconio.h
#includemath.h

void addb(int n,int cnt,int i,char *a)
{
if(n==0) {


{
while(cnt!=0){
a[i++]=')';
 cnt--;  }
//if(cnt==0)
{

   // printf(%s\n,a);
couta\n;

}
return;
}
 }
else
{
 a[i]='(';
addb(n-1,cnt+1,i+1,a);
if(cnt!=0)
 {
a[i]=')';
addb(n,cnt-1,i+1,a);
 }
}
}

void main()
{
 clrscr();
 char *a;
 int n;
 coutn = ;
 cinn;

 a=new char[n*2+1];

 a[n*2]='\0';
 addb(n,0,0,a);

 getch();
}


-- 
Pratik Kathalkar
CoEP
BTech IT
8149198343

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.