[algogeeks] Binary Tree problem - careercup book que4.8

2011-11-25 Thread Swathi
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

[algogeeks] Does anyone have - UNIX internals the new frontiers by Uresh Vahalia

2011-08-31 Thread 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 this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at

Re: [algogeeks] fork()

2011-08-31 Thread Swathi
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

Re: [algogeeks] Re: Static variable

2011-08-31 Thread Swathi
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

Re: [algogeeks] C output

2011-08-31 Thread Swathi
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

Re: [algogeeks] Re: Static variable

2011-08-31 Thread Swathi
: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

Re: [algogeeks] Re: fork()

2011-08-31 Thread Swathi
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

Re: [algogeeks] Static variable memory location

2011-08-31 Thread Swathi
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

Re: [algogeeks] Ebay Recruitment

2011-08-18 Thread Swathi
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

[algogeeks] Any one has IPC (Inter Process Communication) good materia?

2011-07-30 Thread 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 this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at

[algogeeks] IPC Material

2011-07-26 Thread Swathi
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

[algogeeks] Any good book on design patterns?

2011-07-24 Thread 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 this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at

[algogeeks] Re: Any good book on design patterns (C++, not JAVA)?

2011-07-24 Thread Swathi
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

[algogeeks] Re: Any good book on design patterns (C++, not JAVA)?

2011-07-24 Thread Swathi
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

Re: [algogeeks] Find the Row ..

2011-07-18 Thread Swathi
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

Re: [algogeeks] Re: MICROSOFT

2011-07-18 Thread Swathi
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);

Re: [algogeeks] MS Ques

2011-07-18 Thread Swathi
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

Re: [algogeeks] Ever growing sorted linked list

2011-07-18 Thread Swathi
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

Re: [algogeeks] Find the Row ..

2011-07-18 Thread Swathi
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

Re: [algogeeks] static vs dynamic array

2011-07-18 Thread Swathi
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

Re: [algogeeks] Output

2011-07-18 Thread Swathi
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 =

Re: [algogeeks] Find the Row ..

2011-07-18 Thread Swathi
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

Re: [algogeeks] Re: Amazon

2011-07-07 Thread Swathi
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

Re: [algogeeks] Re: Amazon

2011-07-07 Thread Swathi
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

Re: [algogeeks] Re: Amazon

2011-07-07 Thread Swathi
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

Re: [algogeeks] Re: Amazon

2011-07-07 Thread Swathi
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

Re: [algogeeks] Re: Amazon

2011-07-07 Thread Swathi
, 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

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-29 Thread Swathi
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

[algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread Swathi
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

[algogeeks] Amazon - max substring

2011-06-29 Thread Swathi
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

Re: [algogeeks] Re: GOOGLE QUESTION

2011-06-29 Thread Swathi
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:

Re: [algogeeks] BST

2011-06-29 Thread Swathi
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

Re: [algogeeks] Amazon - max substring

2011-06-29 Thread Swathi
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

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread Swathi
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

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread Swathi
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

Re: [algogeeks] Amazon - max substring

2011-06-29 Thread Swathi
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

Re: [algogeeks] Amazon - max substring

2011-06-29 Thread Swathi
/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

Re: [algogeeks] Anyone have The google resume book

2011-06-27 Thread Swathi
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

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Swathi
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

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Swathi
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

Re: [algogeeks] Reverse

2011-06-27 Thread Swathi
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) {

[algogeeks] Anyone have The google resume book

2011-06-26 Thread 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 this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at

Re: [algogeeks] Re: Google Question

2011-06-23 Thread Swathi
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

Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-06-23 Thread Swathi
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

[algogeeks] Amazon - Longest palindrome in a string in O(n)

2011-06-21 Thread Swathi
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