Re: [algogeeks] Amazon interview question

2012-05-24 Thread Aman Raj
array of bits?
if the current integer is present set the bit if else make it zero,
searching, insertion and deletion all in O(1) time.

On Thu, May 24, 2012 at 4:15 PM, rishabh shukla rockrishabh.mn...@gmail.com
 wrote:

 Suggest a data structure for storing million trillion numbers efficiently
 in very less space. Means space complexity should be as less as possible

 --
 Rishabh Shukla
 B.Tech Final Year
 MNNIT 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] # of paths betweek two nodes in a DAG

2012-05-24 Thread Ashish Goel
My bad, i am not able to conceptualize this known problem, can anyone help

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652

-- 
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] Amazon interview question

2012-05-24 Thread Ashish Goel
What is the purpose of these numbers, if the idea is to manage a free pool,
then probably 10-ary-tree is the solution. May be Tiger Tree Hash a better
answer where it is tree to say level 7 and then for rest three digits it
become hash table. This way, the chunks can be kept on different machines
too.

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Thu, May 24, 2012 at 4:51 PM, Aman Raj amanka...@gmail.com wrote:

 array of bits?
 if the current integer is present set the bit if else make it zero,
 searching, insertion and deletion all in O(1) time.


 On Thu, May 24, 2012 at 4:15 PM, rishabh shukla 
 rockrishabh.mn...@gmail.com wrote:

 Suggest a data structure for storing million trillion numbers efficiently
 in very less space. Means space complexity should be as less as possible

 --
 Rishabh Shukla
 B.Tech Final Year
 MNNIT 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.


-- 
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] Amazon interview question

2012-05-24 Thread Ashish Goel
refer http://www.cs.bell-labs.com/cm/cs/pearls/sol01.html
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Thu, May 24, 2012 at 6:00 PM, Ashish Goel ashg...@gmail.com wrote:

 What is the purpose of these numbers, if the idea is to manage a free
 pool, then probably 10-ary-tree is the solution. May be Tiger Tree Hash a
 better answer where it is tree to say level 7 and then for rest three
 digits it become hash table. This way, the chunks can be kept on different
 machines too.

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Thu, May 24, 2012 at 4:51 PM, Aman Raj amanka...@gmail.com wrote:

 array of bits?
 if the current integer is present set the bit if else make it zero,
 searching, insertion and deletion all in O(1) time.


 On Thu, May 24, 2012 at 4:15 PM, rishabh shukla 
 rockrishabh.mn...@gmail.com wrote:

 Suggest a data structure for storing million trillion numbers
 efficiently in very less space. Means space complexity should be as less as
 possible

 --
 Rishabh Shukla
 B.Tech Final Year
 MNNIT 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.




-- 
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] classic problem to tree to circular doubly linked list

2012-05-24 Thread sanjay pandey
the main code is dis function only:i will explain dis

static Node treeToList(Node root) {
Node aList, bList;

if (root==NULL) return(NULL);*
/* the below next two lines are just lyk inorder traversal...u mst
hv done dis*/*
aList = treeToList(root-small);
bList = treeToList(root-large);

*/* this is for breaking the links of its left n right child nodes
n pointing to itself*/*
root-small = root;
root-large = root;

   * /* Appending leftchild parent n rightchild together in
doublylinked list form */*
aList = append(aList, root);
aList = append(aList, bList);

return(aList);
}

-- 
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] problem of fork()

2012-05-24 Thread Srikrishan Malik(gmail)
because the process which is executed from prompt has exited and the
children are still alive and printing.


On Thu, May 24, 2012 at 8:26 AM, Rajesh Kumar testalgori...@gmail.comwrote:

 #includestdio.h
 main()
 {
 fork();
 fork();
 fork();
 printf(Hello Word\n);
 }

 output ---
 rajeshkumar@rajeshkumar-laptop:~$ ./a.out
 Hello Word
 Hello Word
 Hello Word
 rajeshkumar@rajeshkumarr-laptop:~$ Hello Word
 Hello Word
 Hello Word
 Hello Word
 Hello Word


 Why it is not printed continously?


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




-- 
SK Malik

-- 
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] problem of fork()

2012-05-24 Thread sumit mahamuni
its not about compilers ... its that new kernels kills all the child
processes, if parent gets killed before.. so that is the reason you
are gettin diff reasons

On 5/24/12, himanshu kansal himanshukansal...@gmail.com wrote:
 i know that the program sholud have printed hello word 8 timesbt whn
 i run it, i get diffrnt reslts everytime and on diffrnt compilers...
 please tell the reason

 On Thu, May 24, 2012 at 11:11 AM, rajesh singarapu
 rajesh0...@gmail.comwrote:

 main process have completed till the time all processes processes
 prints Hello World,

 to prevent it, use wait/wait4 family of fucntions.

 ~r

 On Thu, May 24, 2012 at 8:26 AM, Rajesh Kumar testalgori...@gmail.com
 wrote:
  #includestdio.h
  main()
  {
  fork();
  fork();
  fork();
  printf(Hello Word\n);
  }
 
  output ---
  rajeshkumar@rajeshkumar-laptop:~$ ./a.out
  Hello Word
  Hello Word
  Hello Word
  rajeshkumar@rajeshkumarr-laptop:~$ Hello Word
  Hello Word
  Hello Word
  Hello Word
  Hello Word
 
 
  Why it is not printed continously?
 
 
  --
  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
  Himanshu Kansal
Msc Comp. sc.
 (University of Delhi)

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- So once you do know what the question actually is, you'll know what the
answer means.
-- Perhaps the most important principal for good algorithm designer is to
refuse to be content. - Aho, Hopcroft and Ullman.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

-- 
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] Algorithm Question

2012-05-24 Thread sanjay pandey
min heap wid N elements containing first line from each file will do...
remove the top most n insert next one from dat file only

-- 
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 Q : all anagrams next to each other

2012-05-24 Thread Anika Jain
I have a doubt. If u r doing inplace sorting of a word during checks for a
word, wouldnt that change that word there itself? then how will the
original anagram get restored to arrange in the output in sorted manner?

On Thu, May 24, 2012 at 5:54 PM, Jitender Kumar jitender...@gmail.comwrote:

 The complexity will be (N^2)W because the sorting can be done linear time
 O(W) for strings.


 On Thu, May 24, 2012 at 3:44 PM, WgpShashank 
 shashank7andr...@gmail.comwrote:

 Yeah , its the in-place approach strikes in mind at first look , just
 slightly clearing the complexity to O(N^2* Wlog(W)) , N is number of
 words in array  W is length of longest word in array , let me know i
 missed something ?

  original eat I ate att I the eel eth het
  after sorting  I I ate att can eat eel eth het the

 output should be  I I ate eat att can eel eth het the

 Shashank Mani Narayan
 Computer Science  Engineering
 Birla Institute of Technology,Mesra
 Founder Cracking The Code Lab  http://shashank7s.blogspot.com/;
 FB Page http://www.facebook.com/pages/LestCode
 Google+ http://gplus.to/wgpshashank
 Twitter https://twitter.com/wgpshashank;
 Puzzled Guy @ http://ashutosh7s.blogspot.com;
 FB Page http://www.facebook.com/Puzzles.For.Puzzled.Minds


 On May 22, 8:18 am, Navin Gupta navin.nit...@gmail.com wrote:
  It can be done inplace, then Time Complexity will be O( N^2 x W ) where
 N
  is no. of words and  W is word size.
  Start from the left and sort the current word.
  Keep a pointer  PTR  to the first index of the element left to process.
  Initially it will be 0.As we add words this pointer moves forwards.
  Now iterate the whole list of words to find all those words having same
  sorted sequence i.e. anagrams
  Whenver we get a word which is anagram of the current string, swap it
 with
  the string  pointed by PTR, move PTR forward.
 
  pseudoCode :-
 
  func( vectorstring v)
  {
 int n=v.size();
 for(int i=0;in;i++)
 {
string currentWord = v[i];
sort(currentWord);
for(int j=i+1;jn;j++)
{
if ( sort(v[j]) == currentWord )// anagrams found,
{
 swap( v[i] , v[j] ); //move this string
 to
  the position next to pos of currentWord
   i++;//and move the
 index
  of currentWord forward
}
   }
 
 
 
 
 
 
 
  }

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

 Jitender Kumar
 3rd year (Computer Engineering)
 NIT Kurukshetra
 Kurukshetra- 136119
  Mobile  +91-8529035751

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

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