Re: [algogeeks] Fork in c

2012-10-27 Thread CHIRANJEEV KUMAR
I think the output should be : text1text2 text2 On Sat, Oct 27, 2012 at 2:22 PM, rahul sharma rahul23111...@gmail.comwrote: int main() { printf(text1); fork(); printf(text2\n); return 0; } the output is: text1text2 text1text2 Please explain o/p -- You

Re: [algogeeks] BIG O

2012-10-27 Thread CHIRANJEEV KUMAR
O(log( n! )); On Sat, Oct 27, 2012 at 6:03 AM, payal gupta gpt.pa...@gmail.com wrote: That 's correct. On Sat, Oct 27, 2012 at 3:25 AM, rahul sharma rahul23111...@gmail.comwrote: for k=1 to n { j=k; while(j0) j=j/2; } the complexity is big o is o(nlogn) am i ryt -- You

Re: [algogeeks] BIG O

2012-10-27 Thread anil sahu
Yes, its complexity is O(nlogn). On Sat, Oct 27, 2012 at 2:35 PM, CHIRANJEEV KUMAR cse.chiranj...@gmail.comwrote: O(log( n! )); On Sat, Oct 27, 2012 at 6:03 AM, payal gupta gpt.pa...@gmail.com wrote: That 's correct. On Sat, Oct 27, 2012 at 3:25 AM, rahul sharma

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread payal gupta
it jst the pnc involved here Clearrly, every string here is formed out a,b,c,x ,y z . if we notice here 'a' always occurs before 'b' which occurs after 'c' in any string that would be generated by the fsm here. Same holds for the combination x ,y ,z . So basically it reduces to a problem in

Re: [algogeeks] Fork in c

2012-10-27 Thread saurabh singh
printf is line buffered. hence text1 remains in buffer when fork is called.this is shared by both the child and the parent when fork is called. Leaving the rest for u to conclude Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, Oct 27, 2012 at 2:25

Re: [algogeeks] Sequence Point C with postincremented

2012-10-27 Thread Saurabh Kumar
You're right , || all introduce a sequence point. In first case evaluation proceeds like this: j = (i++, i++); *i++* Post increment the i (i is now 11) *j = i++* Post increment the i (j is assigned 11 and i is now 12) In second case, the whole of rvalue for = operator will be evaluated

Re: [algogeeks] INTERVIEW QUESTION

2012-10-27 Thread Saurabh Kumar
could you please share the link? coz at first glance a Trie looks like a bad choice for this task. I'd go with the Levenshtein distance and a kd-tree. First implement the Levenshtein distance algorithm to calculate the edit distance of two strings. Second, since Levenshtein distance qualifies as

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread Saurabh Kumar
20 seems correct. You can also view this as all permutations of xyzabc such that the ordering xyz and abc should appear as is. On 27 October 2012 05:57, payal gupta gpt.pa...@gmail.com wrote: should be 6C3 or 20 perhaps. On Sat, Oct 27, 2012 at 3:29 AM, rahul sharma

Re: [algogeeks] BIG O

2012-10-27 Thread Pralay Biswas
Yes! On Fri, Oct 26, 2012 at 2:55 PM, rahul sharma rahul23111...@gmail.comwrote: for k=1 to n { j=k; while(j0) j=j/2; } the complexity is big o is o(nlogn) am i ryt -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Pre/Post L and r value

2012-10-27 Thread Saurabh Kumar
i++: Post increment can't be a lvalue because Post increment internally returns a temporary object (NOT the location of i) hence you cannot assign anything to it. The result of i++ can be used only as a rvalue. ++i: whereas, in Pre-increment value gets incremented and the same location is

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread Saurabh Kumar
Since this is a small grid you can count it manually but in general problem is to count no. of paths from bottom-left corner to top-right corner (provided all the transition alphabets in the automata are distinct in the respective dimensions e.g. here, xyz in one dimension and abc in other) You

Re: [algogeeks] INTERVIEW QUESTION

2012-10-27 Thread Saurabh Kumar
Firstly, that question is missing a lot of details. In absence of those details I'm going to make soem assumptions: 1. cube is odd lengthed, so that we can define a unique center of cube. 2. While traversing from a cell(x, y, z) we can only move into any of the 6 adjacent cells[x(+-)1, y(+-)1,

Re: [algogeeks] Re: Random Number generation

2012-10-27 Thread Saurabh Kumar
@Don- Yes, I agree the choice of Random number generator algorithm should very much depend on the underlying application. Thanks, for bringing up the Diehard tests, those are some interesting statistical tests. +1 On 26 October 2012 21:23, Don dondod...@gmail.com wrote: How you chose from the

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
..i under stand with 6!/(3!*3!) method... plz explain from combination point of viewi didnt get ur last linei understand that we need to find no. of permutaions of abcxyz s.t abc and xyz.plz tell how to find thisi understand as someone explained above with VVVHHH method.

Re: [algogeeks] Pre/Post L and r value

2012-10-27 Thread rahul sharma
But y post returns temp. object On Fri, Oct 26, 2012 at 8:18 PM, Saurabh Kumar srbh.ku...@gmail.com wrote: i++: Post increment can't be a lvalue because Post increment internally returns a temporary object (NOT the location of i) hence you cannot assign anything to it. The result of i++ can

Re: [algogeeks] Sequence Point C with postincremented

2012-10-27 Thread rahul sharma
so it means after sequence point the post increment is done...after ht epost increment is incremented and value is reflected...m i ryt? On Fri, Oct 26, 2012 at 8:43 PM, Saurabh Kumar srbh.ku...@gmail.com wrote: You're right , || all introduce a sequence point. In first case evaluation

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
plz help mei am thinking this the following way.. we need to find no. of permutaions of abcxyz s.t abc and xyz.. means we need to form string of 6 length s.t abc and xyz means we have 6 places a- can be placed at 4/6 locations b- can be palced at 4/6 locations c-can be placed at 4/6 locations

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
@payalplz explain how to slect 3 spaces for a.b.c out of 6. we need to put them in orderso look my aboyve post and plz comment On Sat, Oct 27, 2012 at 8:14 PM, rahul sharma rahul23111...@gmail.comwrote: plz help mei am thinking this the following way.. we need to find no. of

Re: [algogeeks] Fork in c

2012-10-27 Thread rahul sharma
text 1 remains in buffer...nowwhen child reaches print f.it prints oldbuffer+newdata...m i ryt??? On Sat, Oct 27, 2012 at 4:07 PM, saurabh singh saurab...@gmail.com wrote: printf is line buffered. hence text1 remains in buffer when fork is called.this is shared by both the child and the

Re: [algogeeks] Fork in c

2012-10-27 Thread saurabh singh
Yup Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, Oct 27, 2012 at 8:21 PM, rahul sharma rahul23111...@gmail.comwrote: text 1 remains in buffer...nowwhen child reaches print f.it prints oldbuffer+newdata...m i ryt??? On Sat, Oct 27, 2012 at

Re: [algogeeks] Re: Range Checking Efficiently C++

2012-10-27 Thread Dave
@Atul: Try x = 0, a = 1, b = 2, for which (x a x b) is false, but (x - a b - x) is true. Dave On Saturday, October 27, 2012 5:43:17 AM UTC-5, ATul SIngh wrote: Thnks but i figured it out as ( x = a x b ) or ( x = a x = b ) could be written as x -a b - xfor first case

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread payal gupta
@rahul ... by my last line i meant that since we got to form a string of 6 chars with the restriction that ab c and xyz should be in order as told by saurabh above. for convenience consider 'spaces' to be 'positions'. Or for better understanding consider this for forming a string with 6

Re: [algogeeks] INTERVIEW QUESTION

2012-10-27 Thread payal gupta
the question mentioned is as it isi just copy pasted it here. @saurabh thanx for the explainaton of the cube problem i guess that is an appropriate soln for the question. and for the other question on detection of typos and suggestion i would like to know to know what 'k' in your

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread Vineeth
we need to find no. of permutations of abcxyz s.t abc and xyz. @Rahul : If you want to solve it as a PC problem, here is the approach : ignoring these conditions abc and xyz, no. of permutations using abcxyz = 6! Now let's handle abc case. in these 6 ! combinations, abc can come in any of