[algogeeks] adobe questions

2012-10-23 Thread saket
There is one linked list having two pointer one as usual next and other is random pointer pointing to any random node in list. write algo to make a duplicate of it. Note:- Original list is const, Can't be modified. i know O(n) solution when list can be modified , and o(n^2) when list can be

Re: [algogeeks] adobe questions

2012-10-23 Thread Apurva Kumar
http://www.geeksforgeeks.org/archives/1155 On Tue, Oct 23, 2012 at 1:36 AM, saket narayan.shiv...@gmail.com wrote: There is one linked list having two pointer one as usual next and other is random pointer pointing to any random node in list. write algo to make a duplicate of it. Note:-

Re: [algogeeks] adobe questions

2012-10-23 Thread atul anand
use hash map...with key as original node and value as duplicate of this node duplicate node next and random pointer is set to NULL initially. now traverse whole linked list keep on adding node. after this do another traversal of orig linked list taking key as orig node ..duplicate=fetch

[algogeeks] amazon question

2012-10-23 Thread saket
We have a long chain of cuboids in all the six directions (six faces). One start node is given and one end node is given. Give a data structure to represent this also search for the given node from start node. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] permutations using a stack

2012-10-23 Thread neeraj bagga
http://en.wikipedia.org/wiki/Catalan_number On Sun, Oct 21, 2012 at 4:00 PM, Shruti Gupta fundooshr...@gmail.comwrote: if n=1,2,3 n we denote Push by P and Pop by X the we can generate following permutations : 1) PPPXXX = 321 2) PPXXPX = 213 3) PXPXPX = 123 4) PXPPXX = 132 5) PPXPXX =

Re: [algogeeks] adobe questions

2012-10-23 Thread saket
@atul +1 On Tuesday, 23 October 2012 14:17:34 UTC+5:30, atul007 wrote: use hash map...with key as original node and value as duplicate of this node duplicate node next and random pointer is set to NULL initially. now traverse whole linked list keep on adding node. after this do another

Re: [algogeeks] amazon question

2012-10-23 Thread bharat b
we can represent in 3-D array .. what type of elements are those .. is there any special kind of formation among elements for searching? we have to think about searching based on the criteria .. On Tue, Oct 23, 2012 at 3:34 PM, saket narayan.shiv...@gmail.com wrote: We have a long chain of

Re: [algogeeks] amazon question

2012-10-23 Thread bharat b
If the requirement is only searching in 3-D .. there is a famous data structure K-D tree. On Tue, Oct 23, 2012 at 5:54 PM, bharat b bagana.bharatku...@gmail.comwrote: we can represent in 3-D array .. what type of elements are those .. is there any special kind of formation among elements for

[algogeeks] Re: Printing all inversions in an array

2012-10-23 Thread Aamir Khan
On Monday, October 22, 2012, Dipit Grover wrote: Since the number of inversions are of order n^2 in the worst case, so should be the complexity of printing them apparently. It makes sense to some extent but this is no proof. There has to be a better proof for lower bound of complexity for

Re: [algogeeks] Re: Printing all inversions in an array

2012-10-23 Thread Carl Barton
That statement is only very superficially similar. Counting them is saying how many of them there are, it doesn't necessarily require you to look at/compute each one. So it is not the same as printing them. If you're saying I want to print out each inversion individually then it's going to be

Re: [algogeeks] Re: Printing all inversions in an array

2012-10-23 Thread Dipit Grover
^ Exactly! Dipit Grover B.Tech in Computer Science and Engineering - lVth year IIT Roorkee, 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,

[algogeeks] T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.

2012-10-23 Thread rahul sharma
We could create a string representing the inorder and preorder traversals. If T2’s preorder traversal is a substring of T1’s preorder traversal, and T2’s inorder traversal is a substring of T1’s inorder traversal, then T2 is a substring of T1 any other method?? we can also do by folloowing 1.