Career cup book question 4.8 - You are given a binary tree in which each
node contains a value. Design an algorithm to print all paths which sum up
to that value. Note that it can be any path in the tree - it does not have
to start at the root.
Answer given in career cup book -
Let’s approach
--
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
20
On Wed, Aug 31, 2011 at 8:57 PM, ravi maggon maggonr...@gmail.com wrote:
Can anyone tell me about this code
#include stdio.h
#include unistd.h
int main()
{
fork();
fork() fork() || fork();
fork();
printf(forked\n);
return 0;
}
The no. of processes spawned and its
C standard doesn't define where static variables has to be stored. All it
says is to persist the data across the multiple function calls. So I think
the answer varies based on the compiler implementation but printing all
zeros makes more logical.
On Wed, Aug 31, 2011 at 9:25 PM, rohit
Depends on the 32-bit or 64-bit...
sizeof(d) - returns the 4 in case of 32-bit, 8 incase of 64-bit
strlen(d) - 3
On Wed, Aug 31, 2011 at 9:32 PM, Dheeraj Sharma dheerajsharma1...@gmail.com
wrote:
8 3 is correct..winshuttle mein aaya tha ;)
On Wed, Aug 31, 2011 at 9:30 PM, aditi garg
:04 AM, Swathi chukka.swa...@gmail.com wrote:
C standard doesn't define where static variables has to be stored. All it
says is to persist the data across the multiple function calls. So I think
the answer varies based on the compiler implementation but printing all
zeros makes more logical
check that
On Wed, Aug 31, 2011 at 9:18 PM, annarao kataru kataruanna...@gmail.com
wrote:
@swathi :: why it is 20 times ?? ur answer is correct but
plz explain the process??
--
You received this message because you are subscribed to the Google
Groups
C standard doens't fine where it has to be stored.. go through this URL
http://www.velocityreviews.com/forums/t443436-where-is-a-static-variable-stored.html
On Wed, Aug 31, 2011 at 9:57 PM, rohit raman.u...@gmail.com wrote:
Where does a static variable get allocated in memory..?
Like
Is it ebay or paypal? Job location?
On Thu, Aug 18, 2011 at 11:26 PM, ROHIT SINGHAL
rohitksingha...@gmail.comwrote:
Guys i m going to appear for ebay any question set or any kinda help for
the same
--
Regards:
Rohit Singhal
--
You received this message because you are subscribed to the
--
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
Does anyone has good material on InterProcessCommunications? Please share.
Thanks in advance.
-Swathi
--
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
--
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
Hi,
I am interested in design patterns book for C++ (not JAVA).
If anyone has good material then please forward me..
Thanks,
Balu
On Sun, Jul 24, 2011 at 8:02 PM, Swathi chukka.swa...@gmail.com wrote:
--
You received this message because you are subscribed to the Google Groups
Algorithm
Hi,
I am interested in design patterns book for C++ (not JAVA).
If anyone has good material then please forward me..
Thanks,
Swathi
On Sun, Jul 24, 2011 at 8:02 PM, Swathi chukka.swa...@gmail.com wrote:
--
You received this message because you are subscribed to the Google Groups
Algorithm
As said by someone already.. inorder to find min and max values it takes
O(n^2).. so i think there is no better solution below O(n^2)
On Mon, Jul 18, 2011 at 10:01 PM, sunny agrawal sunny816.i...@gmail.comwrote:
if i am not getting question wrong.
read only 3 rows
find min and max of
Using recursion we can do in O(1) space complexity and O(n) time
complexity..
int multiply(int a[], int n, int prevproduct, int i)
{
int nextproduct = 1;
if(i=n)
return 1;
nextproduct = multiply(a, n, prevproduct*a[i], i+1);
printf(i=%d product=%d \n , i, prevproduct*nextproduct);
Reversing linked list works.. A followup question will be without using the
reversal...For that we should first traverse the longest linked list such a
way that it's remaining length is equal to other linked list and multiply
using recursion.. After that based on carry.. you should repeat again
The solution to this problem will be a combination of exponential increase
and the binary search..
start = 0;
end = 0;
index =0;
middle = 0;
while (1)
{
if(a[start] == data)
return start;
if(a[end] == data)
return end;
if(data end)
{
start = end;
end = pow(start,2); // here
you didn't answer my questions... I still think you can't do below O(n ^ 2)
can provide code for your program...
On Mon, Jul 18, 2011 at 10:35 PM, ankit sambyal ankitsamb...@gmail.comwrote:
@Swathi : Suppose u read 3 rows. Find the minimum and maximum element
from the elements read from 3 rows
In first 1, you are using malloc() so the memory will be allocated from heap
which holds good till end of your program.. In second case, the memory will
be allocated on the stack.. so once the function is exited, your stack data
will be released...
On Mon, Jul 18, 2011 at 9:49 PM, rj7
Try check if (p == NULL)... may be memory is not allocated...
On Mon, Jul 18, 2011 at 10:52 PM, Balaji S balaji.ceg...@gmail.com wrote:
The following C program segfaults of IA-64, but works fine on IA-32.
* int main()
{
int* p;
p = (int*)malloc(sizeof(int));
*p =
atleast one solution :)
On Mon, Jul 18, 2011 at 10:35 PM, ankit sambyal
ankitsamb...@gmail.comwrote:
@Swathi : Suppose u read 3 rows. Find the minimum and maximum element
from the elements read from 3 rows. 2 cases arise:
1. Min and Max element belong to 1 row
2. Min and Max belong to 2 rows
My solution,
a) First sort the distances.
b) We will consider the first 2 minimum numbers.. They are definitely the
distances between the 3 nodes...
c) Find the sum of the first 2 minimum numbers.. If this sum is outside n
then we simply return all the nodes less than n else remove that sum and
and
repeat this step by finding the next possible minimum sum.
Thanks,
Swathi
On Thu, Jul 7, 2011 at 6:30 PM, Dumanshu duman...@gmail.com wrote:
Initially we can sort the array in O(nlogn) and then given a max
value, find a pair (x,y) in O(n). here n is also of quadratic order if
taken in terms
This will take more time than mine... Mine will be very fast as we are
exiting if the least sum is outside n
On Thu, Jul 7, 2011 at 6:56 PM, yv paramesh yv.param...@gmail.com wrote:
Hi,
a --- 3Km ---b--- 5Km ---c--- 2Km ---d--- 6Km --e
lets arry be 3,5,2,6,8,10,16,7,13,8it can be any
No need.. check my solution...
On Thu, Jul 7, 2011 at 10:39 PM, durgesh kumar durgesh1...@gmail.comwrote:
step:-
1) sort the array
2) remove the smallest and largest element from arary. keep the smallest
elemnt in seperate queue(result)
3) repeat the above untill the array is empty or it
, durgesh kumar durgesh1...@gmail.comwrote:
On Thu, Jul 7, 2011 at 6:41 PM, Swathi chukka.swa...@gmail.com wrote:
My solution,
a) First sort the distances.
b) We will consider the first 2 minimum numbers.. They are definitely the
distances between the 3 nodes...
c) Find the sum
Anyone able to code the dave's proposal to do inoder and reverse of inorder
at the same time?
On Mon, Jun 27, 2011 at 11:32 PM, Swathi chukka.swa...@gmail.com wrote:
Dave,
I am unable to write code for this so i am asking your help.
Thanks,
Swathi
On Mon, Jun 27, 2011 at 11:28 PM, Dave
substrings]
ex - ab12abcabc [not valid as abc is consecutive substring].
Can someone provide the pseudo code with the logic..
Thanks,
Swathi
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks
Given a string (assume there no spaces or punctuations), write a code that
returns the max. length of the string that has repeated more than once.
Thanks,
Swathi
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
Please explain why you think TRIE use more space?
To my knowledge TRIE says lot of memory as the common numbers are saved only
once.. If you have any good reason then please explain and don't make any
single line statements.
On Wed, Jun 29, 2011 at 9:21 PM, MONSIEUR monsieur@gmail.com wrote:
This should be very simple... follow inorder..
Inorder(Node* node, int counter, int N)
{
if(node == null)return;
Inorder(node-left, counter, N);
counter++;
if(counter == N)
{
print(node-data);
return;
}
Inorder(node-right, counter, N);
}
On Wed, Jun 29, 2011 at 9:03 PM, piyush kapoor
It does but i am asked to code.. if you know the code for suffix tree then
please provide..
On Wed, Jun 29, 2011 at 10:30 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
i think suffix tres will do the job if i have not misunderstood the
question...
On 6/29/11, Swathi chukka.swa...@gmail.com
suffix array of the given string with one extra information
tht is frm which index we are considerin suffix
then sort those uffixe pointres
after tht single scan wud do the job
thanks
rajat ahuja
On Wed, Jun 29, 2011 at 10:23 PM, Swathi chukka.swa...@gmail.com wrote:
Write
not make sense.
It the password is valid then it is of length between 5-12 only.
Simple brute force approach will give decent time enough + we will not
waste necessary memory and large line of code.
On Wed, Jun 29, 2011 at 10:38 PM, Swathi chukka.swa...@gmail.com wrote:
Please provide
I dont know why people reply in plain words.. I personally had this
experience and i was asked to code but i couldn't
On Wed, Jun 29, 2011 at 10:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
I dnt think any company is gonna ask u to code suffix tree..:P :P
On 6/29/11, Swathi chukka.swa
/Suffix/
people hv right to decide if they want to WAP or not.
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Wed, Jun 29, 2011 at 10:55 PM, Swathi chukka.swa...@gmail.com wrote:
I dont know why people reply in plain words.. I personally
This book
http://www.amazon.com/gp/product/0470927623/ref=as_li_ss_tl?ie=UTF8tag=care01-20linkCode=as2camp=1789creative=390957creativeASIN=0470927623
Thanks,
swathi
On Mon, Jun 27, 2011 at 6:50 PM, Vivek Srivastava
srivastava.vivek1...@gmail.com wrote:
Hi swathi,
What do you mean exactly
Dave,
Can you provide the psuedo code for this..
Thanks,
Swathi
On Mon, Jun 27, 2011 at 7:30 PM, Dave dave_and_da...@juno.com wrote:
@Sunny. Mea culpa. You are correct. Revised (and correct) algorithm.
Do two inorder traversals, one in the usual (descend to the left
before descendung
Dave,
I am unable to write code for this so i am asking your help.
Thanks,
Swathi
On Mon, Jun 27, 2011 at 11:28 PM, Dave dave_and_da...@juno.com wrote:
@Swathi: No. I think the high level description should be adequate for
you to write your own code or pseudocode, albeit recognizing that you
it works perfectly
On Mon, Jun 27, 2011 at 11:53 PM, hary rathor harry.rat...@gmail.comwrote:
this solution according to sameer statement solution if there is any
problem then pls tell me . here string or char is not being
store anywhere
char * reverse(char *str,int i ,int j)
{
--
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
We just need to find the start and end of the decreasing sequence then we
have to reverse the elements in that decreasing sequence by swapping the
elements at both the edges...
On Thu, Jun 23, 2011 at 2:13 PM, sankalp srivastava
richi.sankalp1...@gmail.com wrote:
@piyush Sinha
How can you do
Can someone send it to me please...
Thanks,
Swathi
On Thu, Jun 23, 2011 at 12:13 PM, pullasunil pullasu...@gmail.com wrote:
Can you mail me the book for Algorithms for Interviews.
On May 5, 10:44 am, Prateek mailtoprat...@gmail.com wrote:
Hey Rajeev,
Can you mail me the pdf of the book
Does any one know how to return the Longest palindrome in a string in
O(n).
From googling i found that we can use suffix trees but there is no code. I
am looking for logic and also for running code.
Thanks,
Swathi
--
You received this message because you are subscribed to the Google Groups
45 matches
Mail list logo