[algogeeks] Re: Ties The Rope With Minimum Cost ..Interesting For Geeks

2011-03-29 Thread awesomeandroid
visit http://code-forum.blogspot.com/2011/01/tying-ropes-in-minimum-cost.html
for explanation of this problem .
Regards
Priyaranjan

On Mar 28, 11:41 am, bittu shashank7andr...@gmail.com wrote:
 you are given n ropes,maybe of different length. the cost of tying two
 ropes is the sum of their lengths.Find a way to tie these ropes
 together so that the cost is minimum.

 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.



[algogeeks] Re: intel puzzle

2011-02-24 Thread awesomeandroid
The only way to get an acute triangle this way is to connect the
diagonals of three adjacent faces. You can select 3 adjacent faces of
a cube in (6*4*2)/(3*2*1) = 8 different ways.

Regards
Priyaranjan
http://code-forum.blogspot.com

On Feb 23, 12:10 am, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
 answer is 8 ,,, duno how









 On Wed, Feb 23, 2011 at 12:31 AM, Sundi sundi...@gmail.com wrote:
  Is it not 8C3 = 56

  On Feb 22, 9:55 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
   Think of the 8 vertices of a given cube. You are allowed to join three
   vertices to form a triangle. How many such unique acute triangles can you
   make ??

   --
   With Regards,
   *Jalaj Jaiswal* (+919019947895)
   Software developer, Cisco Systems
   B.Tech IIIT ALLAHABAD

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

 --
 With Regards,
 *Jalaj Jaiswal* (+919019947895)
 Software developer, Cisco Systems
 B.Tech IIIT ALLAHABAD

-- 
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] Re: intel puzzle

2011-02-24 Thread awesomeandroid
@dave i never said it will be a right angled triangle ,it will be a
equilateral triangle and thus an acute angled triangle.

On Feb 24, 8:38 pm, Dave dave_and_da...@juno.com wrote:
 @Priyaranjan: Suppose that the cube has side 1 and is placed in
 standard position at the origin. Then the triangle with vertices
 (0,0,0), (1,0,1), and (1,1,0) is equilateral with side sqrt(2), and
 therefore is not a right triangle.

 Dave

 On Feb 24, 8:49 am, Vikas Kumar dev.vika...@gmail.com wrote:







  @priyaranjan
  No,Your triangle will be right angle triangle.

  In fact any triangle chosen will be right angle triangle.

  Proof:

  suppose there are 2 planes kept at parallel with each other.(top bottom)
  join corresponding vertices of up to down and form  cube.

  Now 3 points chosen can be on same plane .(means 2 must be adjacent)
  so right angle triangle is only possible

  or at least 2 points are on same plane and 3rd point is other plane(pigeon
  hole as only 2 holes are there for 3 pegions)

  Now as 3 rd point always lies on perpendicular point so triagle formed will
  always be right angled.

  On Thu, Feb 24, 2011 at 5:23 PM, awesomeandroid
  priyaranjan@gmail.comwrote:

   The only way to get an acute triangle this way is to connect the
   diagonals of three adjacent faces. You can select 3 adjacent faces of
   a cube in (6*4*2)/(3*2*1) = 8 different ways.

   Regards
   Priyaranjan
  http://code-forum.blogspot.com

   On Feb 23, 12:10 am, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
answer is 8 ,,, duno how

On Wed, Feb 23, 2011 at 12:31 AM, Sundi sundi...@gmail.com wrote:
 Is it not 8C3 = 56

 On Feb 22, 9:55 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
  Think of the 8 vertices of a given cube. You are allowed to join
   three
  vertices to form a triangle. How many such unique acute triangles 
  can
   you
  make ??

  --
  With Regards,
  *Jalaj Jaiswal* (+919019947895)
  Software developer, Cisco Systems
  B.Tech IIIT ALLAHABAD

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

--
With Regards,
*Jalaj Jaiswal* (+919019947895)
Software developer, Cisco Systems
B.Tech IIIT ALLAHABAD

   --
   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.-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 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] Re: intel puzzle

2011-02-24 Thread awesomeandroid
@vikash kumar please read my answer then give your comment..it will be
a equilateral triangle and not a right angled triangle i.e an acute
angled triangle.

On Feb 24, 7:49 pm, Vikas Kumar dev.vika...@gmail.com wrote:
 @priyaranjan
 No,Your triangle will be right angle triangle.

 In fact any triangle chosen will be right angle triangle.

 Proof:

 suppose there are 2 planes kept at parallel with each other.(top bottom)
 join corresponding vertices of up to down and form  cube.

 Now 3 points chosen can be on same plane .(means 2 must be adjacent)
 so right angle triangle is only possible

 or at least 2 points are on same plane and 3rd point is other plane(pigeon
 hole as only 2 holes are there for 3 pegions)

 Now as 3 rd point always lies on perpendicular point so triagle formed will
 always be right angled.

 On Thu, Feb 24, 2011 at 5:23 PM, awesomeandroid
 priyaranjan@gmail.comwrote:







  The only way to get an acute triangle this way is to connect the
  diagonals of three adjacent faces. You can select 3 adjacent faces of
  a cube in (6*4*2)/(3*2*1) = 8 different ways.

  Regards
  Priyaranjan
 http://code-forum.blogspot.com

  On Feb 23, 12:10 am, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
   answer is 8 ,,, duno how

   On Wed, Feb 23, 2011 at 12:31 AM, Sundi sundi...@gmail.com wrote:
Is it not 8C3 = 56

On Feb 22, 9:55 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
 Think of the 8 vertices of a given cube. You are allowed to join
  three
 vertices to form a triangle. How many such unique acute triangles can
  you
 make ??

 --
 With Regards,
 *Jalaj Jaiswal* (+919019947895)
 Software developer, Cisco Systems
 B.Tech IIIT ALLAHABAD

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

   --
   With Regards,
   *Jalaj Jaiswal* (+919019947895)
   Software developer, Cisco Systems
   B.Tech IIIT ALLAHABAD

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



[algogeeks] Re: Sites for Interview Questions

2011-01-18 Thread awesomeandroid
http://code-forum.blogspot.com

On Jan 19, 7:10 am, rajeev kumar rajeevprasa...@gmail.com wrote:
 tryhttp://www.careercup.com/

 http://www.careercup.com/Thanks,
 rajiv.

 On Tue, Jan 18, 2011 at 7:57 AM, Yellow Sapphire pukhraj7...@gmail.comwrote:









  Hi,

  Can someone suggest good books/websites/blogs for interview related
  questions.

  thanks--
  YS

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

 --
 Thank You
 Rajeev Kumar

-- 
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] Re: Bit Manipulation

2011-01-17 Thread awesomeandroid

@juver i am really sorry ,i forget to mention.ya this soln will work
only if n is even power of 2.

Regards
Priyaranjan
http://code-forum.blogspot.com

On Jan 17, 12:43 pm, juver++ avpostni...@gmail.com wrote:
 @awesomeandroid
 Your solution for Q1 is wrong. It can be applied only for such numbers N =
 2^k, so number should power of 2.

-- 
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] Re: Find duplicate element in an array

2011-01-16 Thread awesomeandroid
@yousaf traversing through the array and if elements have same hash
value doesn't mean that they are repeated. even two different numbers
can have same hash value,so its not guaranteed.

Regards
Priyaranjan
http://code-forum.blogspot.com

On Jan 16, 11:24 am, Yousaf muhammd.you...@gmail.com wrote:
 traverse the array and hash the elements. If an element is already in
 the hashtable, its repeated one.

 On Jan 15, 9:21 pm, nphard nphard nphard.nph...@gmail.com wrote:







  Given an array of integers of size 'n' - consisting of 'n-2' unique integers
  and 1 integer with a duplicate, find the repeated element in O(n).

  Note: This is a converse of finding the unique element in an array
  consisting of duplicates - which can be solved with the XOR technique - but
  I am not sure if the same/similar technique can be applied here.

-- 
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] Re: Find duplicate element in an array

2011-01-16 Thread awesomeandroid
@All as mention earlier by nphard range of numbers is not defined so
we can't use method proposed by dave.and if number are between 1-n
then there are several techniques.

Regards
Priyaranjan
http://code-forum.blogspot.com



On Jan 16, 11:35 pm, yq Zhang zhangyunq...@gmail.com wrote:
 @Dave, your algorithm is a dijkstra cycle finding algo. It requires the
 function to have only ONE SINGLE cycle in the transition function. However,
 the transition function for the array could have several cycles. How could
 you find the duplicate? Can you elaborate more on your solution? Maybe I
 just didn't understand your solution.

 BTW, if it's guranteed the number is between 1...n-2. The simpleset approach
 is SUM(array) - SUM(1...n-2)

 Thanks

 Yq







 On Sun, Jan 16, 2011 at 10:25 AM, Dave dave_and_da...@juno.com wrote:
  Okay. Here is a further exposition of the solution. It took me a while
  to remember where I had used it before.

  i = n
  j = n
  do while not (i = j)
     i = A(A((i))
     j = A(j)
  end
  /* Now a=b can be reached at either 2k or k steps from n, */
  /* where k is some integer between 1 and n. */
  i = n
  do while not (i = j)
     i = A(i)
     j = A(j)
  end
  print a

  Dave

  On Jan 16, 11:57 am, juver++ avpostni...@gmail.com wrote:
   @Dave
   Cycle finding algo (Floyd's, Brent's) can be applied only for the
  iterated
   function values.
   This means: f(x0) = x1; f(x1) = x2 and etc.
   Suppose we have the following array: 1 2 3 2 4. Value 2 have two
  different
   transitions.

   Clarify your proposed method if it needs additional observations.

  --
  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%2Bunsubscribe@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.



[algogeeks] Re: Find duplicate element in an array

2011-01-16 Thread awesomeandroid
if range is defined there are several methods discussed at
http://aperiodic.net/phil/archives/Geekery/find-duplicate-elements.html

Regards
Priyaranjan
http://code-forum.blogspot.com

On Jan 16, 11:35 pm, yq Zhang zhangyunq...@gmail.com wrote:
 @Dave, your algorithm is a dijkstra cycle finding algo. It requires the
 function to have only ONE SINGLE cycle in the transition function. However,
 the transition function for the array could have several cycles. How could
 you find the duplicate? Can you elaborate more on your solution? Maybe I
 just didn't understand your solution.

 BTW, if it's guranteed the number is between 1...n-2. The simpleset approach
 is SUM(array) - SUM(1...n-2)

 Thanks

 Yq







 On Sun, Jan 16, 2011 at 10:25 AM, Dave dave_and_da...@juno.com wrote:
  Okay. Here is a further exposition of the solution. It took me a while
  to remember where I had used it before.

  i = n
  j = n
  do while not (i = j)
     i = A(A((i))
     j = A(j)
  end
  /* Now a=b can be reached at either 2k or k steps from n, */
  /* where k is some integer between 1 and n. */
  i = n
  do while not (i = j)
     i = A(i)
     j = A(j)
  end
  print a

  Dave

  On Jan 16, 11:57 am, juver++ avpostni...@gmail.com wrote:
   @Dave
   Cycle finding algo (Floyd's, Brent's) can be applied only for the
  iterated
   function values.
   This means: f(x0) = x1; f(x1) = x2 and etc.
   Suppose we have the following array: 1 2 3 2 4. Value 2 have two
  different
   transitions.

   Clarify your proposed method if it needs additional observations.

  --
  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%2Bunsubscribe@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.



[algogeeks] Re: Hellof Friends. Regarding Microsoft Internship test

2011-01-16 Thread awesomeandroid
@Rahul
MS is coming to my college for internship as well so i have shared few
questions that they ask in interview and part of coding round.here is
the link..
http://code-forum.blogspot.com/2011/01/microsoft-papers-for-nit-jsr-juniors.html

Regards
Priyaranjan
http://code-forum.blogspot.com

On Jan 17, 12:52 am, sunny agrawal sunny816.i...@gmail.com wrote:
 format of written test MS currently following for interns based on
 my experience
 Q1: given a code, write o/p
 Q2: finding bugs in a program / code a MS standard question
 Q3: code MS standard question
 Q4: writing test cases for give problem
 Q5: Product Designing related

 and in interviews mostly algorithms

-- 
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] Re: Bit Manipulation

2011-01-16 Thread awesomeandroid
Q2.next higher number having equal number of 1's
http://code-forum.blogspot.com/2011/01/next-higher-number-having-equal-number.html

Regards
Priyaranjan

On Jan 16, 9:09 pm, Decipher ankurseth...@gmail.com wrote:
 Q1)An array A[1   n] contains all the integers from 0 to n except for one
 number which is missing . In this problem, we cannot access an entire
 integer in A with a single operation . The elements of A are represented in
 binary, and the only operation we can use to access them is “fetch the jth
 bit of A[i]”, which takes constant time   Write code to find the missing
 integer . Can you do it in O(n) time?

 Q2)Given an integer, print the next smallest and next largest number that
 have the same number of 1 bits in their binary representation .

-- 
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] Re: Bit Manipulation

2011-01-16 Thread awesomeandroid
for Q1. you can do it in o(n) time
Call your missing number M.

You can split your array into two parts depending on whether the least
significant bit of A[i] is a 1 or a 0. The smaller of the two parts
(call it P_1) is at most (n-1)/2 elements in size, and it tells you
whether M's least significant bit is a 1 or a 0.

Now consider the 2nd bit for the elements of P_1. Again, this part can
be split in two, and the smaller of the two parts (P_2) tells you
whether this bit should be a 1 or a 0.

Carry on going (P_3, P_4, ...) until you've worked out what all the
bits are.

Regards
Priyaranjan
http://code-forum.blogspot.com

On Jan 16, 9:09 pm, Decipher ankurseth...@gmail.com wrote:
 Q1)An array A[1   n] contains all the integers from 0 to n except for one
 number which is missing . In this problem, we cannot access an entire
 integer in A with a single operation . The elements of A are represented in
 binary, and the only operation we can use to access them is “fetch the jth
 bit of A[i]”, which takes constant time   Write code to find the missing
 integer . Can you do it in O(n) time?

 Q2)Given an integer, print the next smallest and next largest number that
 have the same number of 1 bits in their binary representation .

-- 
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] Re: Find The Looping Node

2011-01-12 Thread awesomeandroid
you can find explanation of same problem at
http://code-forum.blogspot.com/2010/12/loop-in-linked-list.html

On Dec 22 2010, 8:41 pm, Saurabh Koar saurabhkoar...@gmail.com
wrote:
 Finding whether a loop exists or not in a linked list, is a very
 familiar problem.But I want an algorithm that will find the node that
 is causing the loop.
 Well,I have an approach.Start from the head.Copy its data into an
 array.Mark node's data as infinity.Move to the next node.When u find
 node-next-data=infinity u will say that the current node is causing
 the loop.Then restore the data of the linked list from the array.But I
 think more optimized algorithm is possible.Reply if you know more
 optimized way.

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



[algogeeks] Re: palindrome

2011-01-12 Thread awesomeandroid
@azhar good solution

Thanks and Regards
Priyaranjan
code-forum.blogspot.com

On Dec 22 2010, 1:55 pm, Azhar Hussain azhar...@gmail.com wrote:
 Hi,

    Here is the simple solution

     unsigned int r = v; // r will be reversed bits of v; first get LSB of v
     int s = sizeof(v) * CHAR_BIT - 1; // extra shift needed at end

          for (v = 1; v; v = 1)
          {
                       r = 1;
                       r |= v  1;
                       s--;
          }
         r = s; // shift when v's highest bits are zero
         if (v == r)
               printf(palindrome\n);
         else
               printf(not a palindrome\n);

 source and more optimized 
 versionshttp://www-graphics.stanford.edu/~seander/bithacks.html#BitReverseObv...

 -
 Azhar.

 On Wed, Dec 22, 2010 at 2:09 PM, pacific pacific pacific4...@gmail.comwrote:









  On Wed, Dec 22, 2010 at 12:11 PM, mo...@ismu mohan...@gmail.com wrote:

  if x is a  32 bit number
  if((x0x)==((x16)0x)))
     x's  bit pattern is a polyndrome

  @snehal :Do you want to consider binary representation of 5 as 101 or
  ..0101 ?
  --

  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.

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

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



[algogeeks] Re: MICROSOFT IDC

2011-01-12 Thread awesomeandroid
@davin this solution will work properly.

Thanks and Regards
Priyaranjan
code-forum.blogspot.com

On Jan 12, 3:42 pm, Davin dkthar...@googlemail.com wrote:
 1) Get count of the nodes in first list, let count be c1.
 2) Get count of the nodes in second list, let count be c2.
 3) Get the difference of counts d = abs(c1 – c2)
 4) Now traverse the bigger list from the first node till d nodes so
 that from here onwards both the lists have equal no of nodes.
 5) Then we can traverse both the lists in parallel till we come across
 a common node. (Note that getting a common node is done by comparing
 the address of the nodes)

 On Jan 12, 3:28 pm, juver++ avpostni...@gmail.com wrote:







  However, sorting works faster than your straighforward solution.

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



[algogeeks] Re: kth largest in tree

2011-01-12 Thread awesomeandroid
use rank node http://code-forum.blogspot.com/2010/12/rank-of-node.html#comments

Thanks and Regards
Priyaranjan
code-forum.blogspot.com

On Jan 11, 10:03 pm, snehal jain learner@gmail.com wrote:
 how to find kth largest in bst. u cnt use static/global variable and u
 cnt pass value of k to any function.

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



[algogeeks] Re: amazon questions

2011-01-12 Thread awesomeandroid
@snehal i think for first question both statement are correct.when you
declare const char * cpp then you can not change the value pointed by
this pointer(using this variable),however you can change where it was
pointing.

On Jan 11, 9:58 pm, snehal jain learner@gmail.com wrote:
 1. what is valid in cpp
 char *cp;
 const char* cpp;
 1. cpp=cp 2. cp=cpp

 2 there r 3 ppl A B C
 A can shoot the target 4 out of 5 times B can shoot 6 out of 7 times
 and C can shoot 8 out of  times. 2 people r selected at random. then
 wat is the probability of hitting the target?

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



[algogeeks] Re: amazon questions

2011-01-12 Thread awesomeandroid
@snehal i think for first question both statement are correct.when
you
declare const char * cpp then you can not change the value pointed by
this pointer(using this variable),however you can change where it was
pointing.

Thanks and Regards
Priyaranjan
code-forum.blogspot.com

On Jan 11, 9:58 pm, snehal jain learner@gmail.com wrote:
 1. what is valid in cpp
 char *cp;
 const char* cpp;
 1. cpp=cp 2. cp=cpp

 2 there r 3 ppl A B C
 A can shoot the target 4 out of 5 times B can shoot 6 out of 7 times
 and C can shoot 8 out of  times. 2 people r selected at random. then
 wat is the probability of hitting the target?

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



[algogeeks] Re: quick sort

2011-01-05 Thread awesomeandroid
using randomized version of quick sort time complexity even in the
worst case is o(nlogn)

Regards
priyaranjan
code-forum.blogspot.com

On Jan 5, 12:55 pm, lee steath...@gmail.com wrote:
 how can we make quick sort to run in O(logn) time in worst case??

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



[algogeeks] Re: In place sorting

2010-12-29 Thread awesomeandroid
please visit this blog 
http://code-forum.blogspot.com/2010/12/in-place-merge-sort.html
to see a simple and straight solution to this problem.however if first
array does not have enough space then also it can be done inplace and
still lots of research is going on for this.

On Dec 29, 2:25 pm, monty 1987 1986mo...@gmail.com wrote:
 hi ,
 this is not a research kind of problem i expect a simple answer.







 On Wed, Dec 29, 2010 at 2:33 PM, juver++ avpostni...@gmail.com wrote:
  Use inplace merge algorithms along with merge sort.
 http://www.logiccoder.com/Downloads/krnrd20.pdf

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

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



[algogeeks] Re: 1s and 0s

2010-12-27 Thread awesomeandroid
your first approach is totally correct.

On Dec 22, 12:36 pm, juver++ avpostni...@gmail.com wrote:
 Use bits manipulation tricks.
 1. There is a way to remove a group of consecutive 1's from the right: A = n
  (n + 1). Then check if A==0 then OK.
 2. Second approach: B=n+1, check if B  (B-1) (this checks if B is a power
 of 2, so it contains only 1 set bit) is zero then OK.

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



[algogeeks] Re: Adobe 2010 Written Test C Development

2010-12-21 Thread awesomeandroid
hi shashank,
for sparse polynomial addition we prefer use of linked list.for more
detailed
explanation
http://code-forum.blogspot.com/2010/11/polynomial-addition.html

for getbits function
http://code-forum.blogspot.com/2010/11/getbits-function-in-c.html
visit these links and post your comment if any problem or some
optimization required.

On Dec 21, 4:52 pm, bittu shashank7andr...@gmail.com wrote:
 Write a function getBits that gives bits from a given position p of a
 given number n.

 Diff between typedef and #define?

 Suggest DS for polynomials. Write C program to add two polynomials.

 Regards
 Shashank

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



[algogeeks] Re: Generic Linked list

2010-12-20 Thread awesomeandroid
hi,
you can find an description of same problem at
http://code-forum.blogspot.com/2010/12/generic-linked-list.html
if you find any question please leave a comment.
Regards
Priyaranjan
Software Engg
Samsung RD

On Dec 17, 12:11 pm, siva viknesh sivavikne...@gmail.com wrote:
 How to implement a generic linked list??

 ..this is one of the frequently asked interview question

 ..for this we have to use void pointers

 struct node
 {
  void *data;
  struct node *link;

 };

 ..can anybody plz give more detailed explanation and complete implementation
 on this??
 And what is its use??

 thanks in advance...

 --
 Regards,
 $iva

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



[algogeeks] Discussion on unique-elements-in-an-array

2010-12-19 Thread awesomeandroid
can you please elaborate nature of inputs??
are they partially sorted or may be random.

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



[algogeeks] Re: subsorted array

2010-12-19 Thread awesomeandroid
i have posted this problem along with solution to my blog check :
http://code-forum.blogspot.com/2010/12/find-minimum-length-unsorted-subarray.html

On Dec 18, 10:57 pm, snehal jain learner@gmail.com wrote:
 Given an unsorted array arr[0..n-1] of size n, find the minimum length
 subarray arr[s..e] such that sorting this subarray makes the whole
 array sorted.

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



[algogeeks] Discussion on unique-elements-in-an-array

2010-12-18 Thread awesomeandroid
what is the range of numbers.if the array has numbers between 1 to n
then there can be o(n) solution.

Regards
Priyaranjan
http://code-forum.blogspot.com/

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



[algogeeks] programming puzzles

2010-12-17 Thread awesomeandroid
visit this blog and post solution to mind boggling interview puzzles
http://code-forum.blogspot.com/

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



[algogeeks] Re: SUN Microsystem Question

2010-12-17 Thread awesomeandroid
A compiled language is one where the program, once compiled, is
expressed in the instructions of the target machine. For example, an
addition + operation in your source code could be translated
directly to the ADD instruction in machine code.

An interpreted language is one where the instructions are not directly
executed by the the target machine, but instead read and executed by
some other program (which normally is written in the language of the
native machine). For example, the same + operation would be
recognised by the interpreter at run time, which would then call its
own add(a,b) function with the appropriate arguments, which would
then execute the machine code ADD instruction.

so,compiled language is often faster than interpreted language.

priyaranjan
software engg
http://code-forum.blogspot.com/

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



[algogeeks] programming puzzles

2010-12-12 Thread awesomeandroid
visit this blog
http://code-forum.blogspot.com/
and http://coders-stop.blogspot.com/
for programming puzzles.

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



[algogeeks] Re: Find small strings in big string

2010-12-12 Thread awesomeandroid
KMP and RabinKarp

On Dec 12, 7:07 pm, Prims topcode...@gmail.com wrote:
 Given that you have one string of length N and M small strings of
 length L . How do you efficiently find the occurrence of each small
 string in the larger one

 I heard the best solution for this problem is to use generalized
 suffix tree. Can any one explain the solution for this problem in
 detail

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