Re: [algogeeks] Re: fork() problem

2010-09-05 Thread Aravind
If main process is included then 20... On Sun, Sep 5, 2010 at 12:01 AM, PremShankar Kumar mep...@gmail.com wrote: @albert:- Here you go:- #include unistd.h #includeiostream using namespace std; int Fork(int i) { coutendlForki executed.endl; return fork(); } int main() {

[algogeeks] Re: Simple reVerse

2010-09-05 Thread Shravan
I think I have done it #include stdio.h #include math.h int reverse(int x) { int y,z; if( x 10) return x; else { y=(int)log10(x); //No. of digits in x z=floor(pow(10,y)); // 10 ^ y return ( ( z * (x % 10) )+ reverse(x / 10) );

Re: [algogeeks] Re: Simple Factorial Problem

2010-09-05 Thread SHRISH MISHRA
http://shrishkrish.blogspot.com/ http://shrishkrish.blogspot.com/I will help. Regards Shrish Chandra Mishra cs084...@mnnit.ac.in IIIrd year, Computer Science Deptt., NIT Allahabad On Sat, Sep 4, 2010 at 7:34 PM, jagadish jagadish1...@gmail.com wrote: Further more you are not printing the

Re: [algogeeks] Re: fork() problem

2010-09-05 Thread MOHIT ....
Fork() fork () || fork (); Fork return 0 in child process and non-zero in parent so in child process Fork() only executed not fork()||fork();( stop working if get 0 as previous input); if we get parent after parent only fork of ( ) and initial fork of || get executed;(|| stops if one input is 1

Re: [algogeeks] Why #! ??

2010-09-05 Thread vineeth mohan
First of all in shell script # means that the line is commented. This way shell intepretor dont consider that line for compilation. Also that is the syntax for shebang line - http://linuxshellaccount.blogspot.com/2007/12/shebang-line-introduction-to-porting.html Thanks Vineeth On

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-09-05 Thread soundar
Finding the longest increasing sub sequence and comparing with the original array ...will this method work? -- 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

[algogeeks] Re: Simple Factorial Problem

2010-09-05 Thread Mohsen Amiri
Integer type is too small for carrying 100! which is 10^156ish. you need to emulate these operation in you code On Sep 4, 6:58 am, nuan rahulverma@gmail.com wrote: There is the problem given on thehttps://www.spoj.pl/problems/FCTRL2/ and I'm submitting a solution for the problem but it's

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-09-05 Thread Discover
ya exactly..dp solution is working... On Sep 5, 7:28 am, Gene gene.ress...@gmail.com wrote: I just figured out you are running the first (incorrect) greedy algorithm I tried.  Please try the DP.  It works fine. On Sep 3, 2:18 pm, Discover maniksinghal.n...@gmail.com wrote: @gene: nice

[algogeeks] Re: fork() problem

2010-09-05 Thread sachin
Yes, you are right mohit, the no of processes is indeed 20. but the question asks for the no of new processes created, not the total no of processes. Hence, we subtract the initial process from the final ans, we get 19., which is the required answer...:-) :-) On Sep 4, 11:10 pm, MOHIT

[algogeeks] array divide problem

2010-09-05 Thread Raj Jagvanshi
There is an array of some no only 0-9. You have to divide it into two array such that sum of elements in each array is same. Eg input {1,2,3,4} output {1,4}{2,3} this question of nagaroo company -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] array divide problem

2010-09-05 Thread sharad kumar
find sum of array.let it be =S nw we need to find the S/2 then find out which elements that add to S/2 llr to knpsack.. On Sun, Sep 5, 2010 at 8:07 PM, Raj Jagvanshi raj.jagvan...@gmail.comwrote: There is an array of some no only 0-9. You have to divide it into two array such that sum of

Re: [algogeeks] array divide problem

2010-09-05 Thread wangyanadam1988
This is a classic DP problem. Assuming we have an integer array a[1...N]. We define C(m,n) as below: 1. If we can find a subset of a[1...m] whose sum is n, then C(m,n)=1. 2. Else C(m,n)=0 Easy to find that: C(m,n)=C(m-1,n) || C(m-1,n-a[m]). Got it? Sent from my iPad On Sep 5, 2010, at 7:37 AM,

Re: [algogeeks] Re: fork() problem

2010-09-05 Thread PremShankar Kumar
@Sachin, @Mohit:- You are right 19 new processes will get created. Thanks guys. #include unistd.h #includeiostream using namespace std; int Fork(int i) { //coutendlForki executed.endl; return fork(); } int main() { Fork(1); Fork(2) Fork (3) || Fork