Re: [algogeeks] National Instruments face to face question

2011-04-10 Thread Munish Goyal
2. First find the given node by traversing tree (BFS) At every level
maintain the list of parents of the current level being traversed.
Whereever this node is found, then traverse and print both children of each
parent in the list.

3. Find the paths to each node from root. This can be done by DFS. Once the
2 paths are found then they act like Singly linked list each (from root to
given node).

Now this problem becomes finding  LCA (least common ancestor) of these tree
nodes.

Check to find latest common parent by comparing the nodes at each level.
Wherever comparison breaks, stop.


On Sun, Apr 10, 2011 at 2:54 AM, Anand anandut2...@gmail.com wrote:

 binary tree


 On Fri, Apr 8, 2011 at 11:54 PM, ArPiT BhAtNaGaR 
 arpitbhatnagarm...@gmail.com wrote:

 U sure those r binary tree's  not BST

 On Sat, Apr 9, 2011 at 10:26 AM, Anand anandut2...@gmail.com wrote:

 1, You have 52 cards. How will you make your you distribute cards
 randomly.

 2. You have given a binary tree. Given any node, print the all the nodes
 at the same level.

 3. You have given a binary tree and two given nodes. Find the distance
 between two nodes.

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




 --
 Arpit Bhatnagar
 (MNIT JAIPUR)

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



Re: [algogeeks] Output of the code

2011-04-07 Thread Munish Goyal
Dude Umer. Now i think the output is clear to you.

Anyhow it is not appropriate to instigate in a worldwide group by putting in
such comments and that
too in a trivial (unsolicited, spam) question post.

I hope the moderator takes note of this.
On Mon, Mar 28, 2011 at 1:24 PM, Umer Farooq the.um...@gmail.com wrote:

 btw, true is defined in cpp.


 On Mon, Mar 28, 2011 at 12:54 PM, Umer Farooq the.um...@gmail.com wrote:

 The compiler doesn't want to get killed like poor 
 manihttp://www.allvoices.com/s/event-8408191/aHR0cDovL2JsYWNrY29icmEucG9zdGVyb3VzLmNvbS9leHRyZW1pc3QtaW5kaWEta2lsbHMtdGhlLXBvb3ItcGFycm90LWZvci1wcmU=,
 therfore it is giving a compiler error :P


 On Mon, Mar 28, 2011 at 10:43 AM, balaji a peshwa.bal...@gmail.comwrote:

 the code will give error as there is nothing called true defined.

 On Sun, Mar 27, 2011 at 10:38 PM, Umer Farooq the.um...@gmail.comwrote:

 Hi,

 Can anyone tell me the output of the following code?

 #include iostream.h

 int main()
 {
 .. if (true)
 .. cout  Pakistan will win the WorldCup 2011\n;
 return 0;
 }

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




 --
 A.Balaji

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




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




-- 
Munish

-- 
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: Algo to identify loose ends of each cable in minimum time.

2011-04-06 Thread Munish Goyal
I think Dave is right and his solution also seems correct. Answer is 20KM
i.e. 2 trips.

Good work @Dave.
On Wed, Apr 6, 2011 at 7:43 PM, Dave dave_and_da...@juno.com wrote:

 @Bittu: Actually, this is an easier problem than the Graham-Knowlton
 Problem. It the GKP, you can only connect wires at one end and test at
 the other. In this problem, this restriction is not given. The
 algorithm I presented allows you to identify the wires with two one-
 way trips by first connecting wires at one end and then connecting
 them at the other end.

 Dave

 On Apr 5, 5:27 am, bittu shashank7andr...@gmail.com wrote:
  its the The Graham-Knowlton Problem in their paper this proble4ms i
  published is published
 
  goole it you will get answer  explanation
 
  Thanks  Regards
  Shashank Mani
  CSE, BIT Mesra

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




-- 
Munish

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



[algogeeks] Twist in Towers of Hanoi problem

2011-04-05 Thread Munish Goyal
New problem posted here, just came across it. Asked to a friend in
interview.

http://industryinterviewquestions.blogspot.com/2011/04/twist-in-towers-of-hanoi-problem.html

-- 
Munish

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



[algogeeks] Mathematical puzzle

2011-04-04 Thread Munish Goyal
Hi,

Just posted a new puzzle here, most of you might not have come across this.

http://industryinterviewquestions.blogspot.com/2011/04/find-out-height-of-tree.html

-- 
Munish

-- 
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] Dp problem

2011-04-04 Thread Munish Goyal
I think we can do it this way.

Sum(all boards length) / K = A ( tentative avg. lenght to be painted by each
painter)

Now start from B1, and keep going further till Bi, till Sum(B1-Bi) is less
than A. So this goes to painter P1.

Same way for P2, start from i+1 till j.

Condition: If  i+1 itself is  A. Then new A = length(B i+1).

Keep going like this till Bn


On Mon, Apr 4, 2011 at 3:20 PM, rajat ahuja catch.rajatah...@gmail.comwrote:

 like u hav boards of length of length
 7 2 6 9 4 and u hav 3 painters who can work ||ly
 so now
 one way to distribute is
 (7 )(2 6 9) (4) so time in ths case is 17
 suppose we do (7 2)(6)(9 4) time  in ths case is 13
 or i can do (7 2)(6 9 )(4) time in ths case is 15
  i m takin 1 unit time to paint one meter so it is directly equal to length



 so we hav to make time and ans is 13

 On Mon, Apr 4, 2011 at 3:11 PM, Rakib Ansary Saikot 
 ansaryfantas...@gmail.com wrote:

 I didnt quite get this problem. Sample case?

 On 4/4/11, rajat ahuja catch.rajatah...@gmail.com wrote:
  You have to paint N boards of length {B1, B2, B3… BN}. There are K
 painters
  available and you are also given how much time a painter takes to paint
 1
  unit of board. You have to get this job done as soon as possible under
 the
  constraints that any painter will only paint continuous sections of
 board,
  say board {2, 3, 4} or only board {1} or nothing but not board {2, 4,
 5}.
 
  --
  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.
 
 

 --
 Sent from my mobile device

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




-- 
Munish

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



[algogeeks] Algo to identify loose ends of each cable in minimum time.

2011-04-04 Thread Munish Goyal
Hi,

Just posted another problem, which comes in category of hard problems.

http://industryinterviewquestions.blogspot.com/2011/04/least-number-of-trips-to-number-wires.html

-- 
Munish

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