[algogeeks] Re: thanx to all

2012-03-01 Thread pavan
congrats :)

On Feb 29, 8:28 pm, Umer Farooq the.um...@gmail.com wrote:
 congratz dude! :-)

 And best of luck with your future endeavours.

 On Wed, Feb 29, 2012 at 11:05 PM, Ravi Ranjan ravi.cool2...@gmail.comwrote:









  @all

  3 round liye

  1.5 hours each  only data structure n algorithm n 2 qstns from OS but
  ultimately the code for synchronization(a mix situation of linked-list n
  semaphore)

  they asked linked list tree programs their variations(all to implement in
  C)

  i stuck at this place when they tell me to write minimum separation
  distance between two nodes of tree
  first i use recursion then
  then they tell to write using one recursion and one loop.  :P
  and tell me to explain the stack  formation on memory layout along with
  its complexity...
  i got confused whther combining both loops and stack have same as that of
  two loops/ two recursions
  basically they are creating  some mental pressure for me by confusing me
  crtisizing me.. i was tired till the last interview
  but finally they hired me. :D:D:D:D

  the last round was the difficult one here they are focussin on graph... my
  graph is little weak(implementation part)

  i think most of the qstns were of MS and Amazon(trees n graph optimization)
  and is discussed here..

  thanx a lot to you guys...

  --
  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.

 --
 Umer

-- 
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: thanx to all

2012-03-01 Thread Ravi Ranjan
@atul

two nodes were given in the qstn...

i did

1) calculate the level of one node through level order traversal similarly
for other
2) then find the Least Common Anscestor
3) then dist(LCS - node1) + dist(LCS - node2)

but i think this was not optimized bcse he was not very much satisfied by
this

So if any of you know some bettr approach then please tell

thanks a lot :)

-- 
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: thanx to all

2012-03-01 Thread atul anand
@Ravi : yeah dere is..and it was discussed before on this group..

check out this link :-
check soln by Lucifier..

http://groups.google.com/group/algogeeks/browse_thread/thread/9bbdd33a6b1e1c5f/fab5d6ad3840b74d?hl=enlnk=gstq=Find+the+path+in+two+nodes+of+a+binary+search+tree#fab5d6ad3840b74d


On Thu, Mar 1, 2012 at 9:18 PM, Ravi Ranjan ravi.cool2...@gmail.com wrote:

 @atul

 two nodes were given in the qstn...

 i did

 1) calculate the level of one node through level order traversal similarly
 for other
 2) then find the Least Common Anscestor
 3) then dist(LCS - node1) + dist(LCS - node2)

 but i think this was not optimized bcse he was not very much satisfied by
 this

 So if any of you know some bettr approach then please tell

 thanks a lot :)

  --
 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.



Re: [algogeeks] Re: thanx to all

2012-03-01 Thread Ravi Ranjan
@atul

thanx dude..

yeah it is the soln...

i think in interview i quite tired thats why unable to think in this simle
way...
again thanx a lot atul  and all other GEEKS :) :)

-- 
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] puzzle

2012-03-01 Thread Gaurav Popli
great observation
thanks!!

On Wed, Feb 29, 2012 at 10:31 PM, Anurag atri anu.anurag@gmail.com wrote:
 @shady:
 Observation only ..

 On Wed, Feb 29, 2012 at 9:03 PM, shady sinv...@gmail.com wrote:

 anurag how did you reach that solution ?
 can you elaborate...


 On Wed, Feb 29, 2012 at 8:11 PM, Anurag atri anu.anurag@gmail.com
 wrote:

 nth term : (n! + 2^n - n)


 On Wed, Feb 29, 2012 at 11:05 AM, Vaibhav Mittal
 vaibhavmitta...@gmail.com wrote:

 Ntn else is provided..??

 On Feb 28, 2012 12:51 PM, Gaurav Popli abeygau...@gmail.com wrote:

 Given a sequance of natural numbers.

 Find N'th term of this sequence.

 a1=2, a2=4, a3=11, a4=36, a5=147, a6=778 ... ... ... ... aN.


 this is a coding quesn and O(n) soln is also welcome...

 --
 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.




 --
 Regards
 Anurag Atri


 --
 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.




 --
 Regards
 Anurag Atri
 III year
 Computer Engineering
 Delhi College Of Engineering


 --
 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.



Re: [algogeeks] Re: Structural Padding in C

2012-03-01 Thread Karunakar Reddy
thank u.



On Wed, Feb 29, 2012 at 6:36 PM, Gene gene.ress...@gmail.com wrote:

 Draw a picture!

 char goes at 0 because it can go anywhere

 short goes at 2 because it must be on a 2-byte boundary;  it consumes
 bytes 2 and 3

 char goes at 4 because this is the next byte after the short; it
 consumes byte 4; byte 5 is the next byte free

 long goes at 8 because this is the next 4-byte boundary after 5

 8 + 4 = 12, so the struct takes 12 bytes

 On Feb 29, 12:03 pm, Karunakar Reddy karunakar.r...@gmail.com wrote:
  how in the second case it is 12?can u tell the clear expl..
 
 
 
 
 
 
 
  On Wed, Feb 29, 2012 at 8:39 AM, Gene gene.ress...@gmail.com wrote:
   This depends on the compiler and even on the options you give the
   compiler.  The C nor C++ standards don't say.
 
   So the asker of the question hasn't give you enough information.
 
   If you assume 32-bit x86 gcc with no packing options or pragmas, I
   think shorts (which are 2 bytes long) are aligned on 2-byte
   boundaries.  Longs and ints (both 4 bytes long) are on 4-byte
   boundaries.  Chars (1 byte) can go anywhere.  If you follow these
   rules, then the first will be laid out:
 
   Field @ Offset
 
   a @ 0 // next 3 bytes are padding to reach next 4-byte boundard
   b @ 4
   c @ 8 // next 2 bytes are padding
   d @ 12
 
   so the struct will be 16 bytes in size (a long is 4 bytes).
 
   In the second case you'll have
 
   a @ 0  // next 1 byte are padding
   b @ 2
   c @ 4  // next 3 bytes are padding
   d @ 8
 
   so the struct will be 12 bytes in size.
 
   Even if you are using a 64-bit gcc (without the -m32 flag), you'll get
   an entirely different answer!
 
   On Feb 29, 11:13 am, Decipher ankurseth...@gmail.com wrote:
I need some help in understanding how padding works ??
Please answer the following questions with proper explanations..
 
struct mystruct1
{
  char a;
  int b;
  short c;
  long d;
 
};
 
struct mystruct2
{
  char a;
  short b;
  char c;
  long d;
 
};
 
What's the sizeof above 2 structures and why ??
 
   --
   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.



-- 
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.