amruthkesav.s
BAN USER- 0of 0 votes
Answersfind the intersection point of 2 linked list (without hashing at a lesser complexity preferably O(m+n))....
- amruthkesav.s
..(the 2 nodes from the seperate lists point to a same node from which the list continues as a single list)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm
{f -fork, p - print
f ->f -> f ->p
f f p
f p ->p
p ->p
|
f ->p
p}
gr8 solution
- amruthkesav.s August 03, 2011Behavior is undefined.... If an object is modified twice within an sequence point, the state of the object is undefined. A sequence point can be a ',' , '&&' , '||'...
- amruthkesav.s August 02, 20111. Find the prime factors of the number.
2. As soon as you find a factor say f, increment the count a[f] (an array already intialized to zero)
3. So after the divisors are found if the array 'a' has even values, then it is a perfect square.
If we store the heap in main memory and do the process, at most only k elements would be stored in the memory. So we may not utilize the memory efficiently?
- amruthkesav.s July 17, 2011
sorry for the poor post
- amruthkesav.s September 16, 20111) the parent invokes ffp (i), fp (ii), p
2) Now (i) invokes fp(iii),p
3) (ii) invokes p
4) (iii) invokes another p
There are 7 p's plus the parent prints once. So totally there are 8 "hellos" printed. Forking creates a child process and the excecution of the child process begins following the fork that is used to invoke it. So the output changes if the print statement position changes.