Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread saurabh koar
Ohhh... Sorry sorry... silly question... Was thinking complexly :( On Tue, Nov 22, 2011 at 1:28 PM, Anika Jain anika.jai...@gmail.com wrote: yes.. On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote: Can a function return a void pointer ? -- You received this message

Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread saurabh koar
Ignore the previous post.. Was meant for some other post :) On Tue, Nov 22, 2011 at 1:39 PM, saurabh koar koarsaur...@gmail.com wrote: Ohhh... Sorry sorry... silly question... Was thinking complexly :( On Tue, Nov 22, 2011 at 1:28 PM, Anika Jain anika.jai...@gmail.comwrote: yes.. On Tue

Re: [algogeeks] A SIMPLE C++ PROGRAM.

2011-05-01 Thread Saurabh Koar
The above code is purely compiler dependent.Google Sequence Points. -- 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

Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-23 Thread Saurabh Koar
ya,u r right.U can find max and min by O(n) time.Bt I already mentioned that there will be additional space complexity.If u want to avoid that u can follow juver++ approach other than ur solution. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: difference x

2010-12-22 Thread Saurabh Koar
@Snehal: U r going crazy man.U r blindly picking up problems and throwing them in this group.It is not a place solving ur homework problems.Plz post problems which r either tricky so that the members can learn something or post problems which u cant solve after giving a measurable effort.Try to

Re: [algogeeks] Re: N companies merge

2010-12-22 Thread Saurabh Koar
@Prims:Only 2 companies are involved in merging?? Or a merger may cover more than two companies?? If a merger can involve more than two companies then the ans is I think ((2^N)-1)-N -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

[algogeeks] Find The Looping Node

2010-12-22 Thread Saurabh Koar
Finding whether a loop exists or not in a linked list, is a very familiar problem.But I want an algorithm that will find the node that is causing the loop. Well,I have an approach.Start from the head.Copy its data into an array.Mark node's data as infinity.Move to the next node.When u find

Re: [algogeeks] Re: difference x

2010-12-22 Thread Saurabh Koar
@Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which r very basic.As u solved the looping prob in other thread I think u r intelligent enough to solve this prob(difference x) easily and also some other probs posted by u(not all).Some problems posted by u are really very tricky

Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread Saurabh Koar
Use count sort logic.It will be O(n). Bt space complexity matters there. -- 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 from this group, send email to

Re: [algogeeks] Re: maximize result

2010-12-21 Thread Saurabh Koar
@Prims: It looks something like this: take an array num to store:3 6 7 3 2 (sequentially as it is) Take another array op : + * + * (sequentially as it is) Now make a 5X5 2-D array maxResult where maxResult[i][j] means maximum value of the subexpression form num[i] to num[j] Here n=5; so u have to

Re: [algogeeks] Re: maximize result

2010-12-21 Thread Saurabh Koar
It is given in the question Given an expression E of n numbers with *, + operations.So,I dont think that min array is required is required in this case. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Amazon Interview Question about Linked Lists

2010-12-21 Thread Saurabh Koar
@Nikhil: ya..rt -- 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 from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit

Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread Saurabh Koar
@Nikhil: What if the array is 1 2 3 4 9 6 6 6 5 and k=3 ? -- 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 from this group, send email to

Re: [algogeeks] bits groups

2010-12-21 Thread Saurabh Koar
@Terence: I think the above fails for 0X.Correct me if I m wrong. -- 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 from this group, send email to

Re: [algogeeks] sort

2010-12-21 Thread Saurabh Koar
See External Sort at Wiki. -- 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 from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] complete tree

2010-12-21 Thread Saurabh Koar
Find the first node whose left child is NULL or Right child is NULL using BFS.(As the tree is complete,all nodes before this will have two children).Insert at that node. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Re: Minimum Triplet Distance

2010-12-20 Thread Saurabh Koar
@Dave : Ya I understand.Thank u. @yq: Sorry!! :( -- 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 from this group, send email to

Re: [algogeeks] Amazon Interview Question about Linked Lists

2010-12-20 Thread Saurabh Koar
temp=head; temp1=temp-fwd; while(temp-fwd!=NULL) { temp2=temp; while(temp2-down!=NULL) temp2=temp2-link; temp2-down=temp1; temp-fwd=NULL; temp=temp1; temp1=temp1-fwd; } U can print the linked list using down pointer.Hope this will work.Correct me if I m wrong. -- You

Re: [algogeeks] Amazon Interview Question about Linked Lists

2010-12-20 Thread Saurabh Koar
@Rishi:I think Shiva's code is also fine.U can access the list easily by using down pointer in his code. Because he is assigning temp-down=temp2 and then he is making temp-fwd=NULL. On 12/20/10, Saurabh Koar saurabhkoar...@gmail.com wrote: temp=head; temp1=temp-fwd; while(temp-fwd!=NULL

Re: [algogeeks] Amazon Interview Question about Linked Lists

2010-12-20 Thread Saurabh Koar
@Rishi:I think Shiva's code is also fine.U can access the list easily by using down pointer in his code. Because he is assigning temp-down=temp2 and then he is making temp-fwd=NULL. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Re: maximize result

2010-12-20 Thread Saurabh Koar
@juver++: Do we need a 2-D array or 1-D array will be sufficient? That means if I take 1-D array then max[i] will represent the maximum value of the subexpression from 0 to i.and for i+1 we will use the result we have got in max[i].Thus we will be able to calculate max[N-1] which is the maximum

Re: [algogeeks] Re: Minimum Triplet Distance

2010-12-20 Thread Saurabh Koar
@yq: Can u plzz inform what was ur approach/logic while deriving the condition that index will be increased of that array which contains minimum of three elements to get the desired ans? It will be very helpful.Thanks in advance. -- You received this message because you are subscribed to the

Re: [algogeeks] Re: maximize result

2010-12-20 Thread Saurabh Koar
@juver++: gt it.thanks -- 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 from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options,

[algogeeks] Minimum Triplet Distance

2010-12-19 Thread Saurabh Koar
You are given 3 integer arrays A, B and C of length n1, n2 and n3 respectively. All arrays are sorted. We define triplet of these 3 arrays as (x,y,z) where x is any integer from A, y from B and z from C. We define distance of triplet as maximum difference among triplet elements, i.e. Maximum of x

Re: [algogeeks] Minimum Triplet Distance

2010-12-19 Thread Saurabh Koar
@yq: Plz explain your algorithm. On 12/20/10, yq Zhang zhangyunq...@gmail.com wrote: Are A, B, C sorted? If so, I believe there is a O(n1+n2+n3) solution for this question. Thanks On Sun, Dec 19, 2010 at 9:57 AM, Saurabh Koar saurabhkoar...@gmail.comwrote: You are given 3 integer arrays

Re: [algogeeks] Minimum Triplet Distance

2010-12-19 Thread Saurabh Koar
@yq: Heyy yq..I m not interested in what is equivalent to what and what is not not equivalent to what..I m interested to a specific optimized algorithm for the specific problem stated above.If u can figure out equivalence u can also devise the algorithm for the above problem.Nw would u please

Re: [algogeeks] Minimum Triplet Distance

2010-12-19 Thread Saurabh Koar
@yq: Thanks!! -- 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 from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this

Re: [algogeeks] microsoft interview question

2010-12-17 Thread Saurabh Koar
http://cslibrary.stanford.edu/109/TreeListRecursion.html -- 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 from this group, send email to

Re: [algogeeks] Re: C aps ques

2010-12-14 Thread Saurabh Koar
Exactly!! On 12/14/10, RAHUL KUJUR kujurismonu2...@gmail.com wrote: correct me if I am wrong. -- 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 from this group,

Re: [algogeeks] C output... ???

2010-12-14 Thread Saurabh Koar
When u r passing an array to a function u only pass the base address nt the total array...bt when sizeof is applied in main() u hv the whole array. Thats why in the first case the output is 4(only one address that is capable of holdin one integer)bt in the 2nd case the output is 40(as u hv 10

Re: [algogeeks] iTS aLL GOOGLE- iNTERVIEW

2010-12-14 Thread Saurabh Koar
How abt this?? #includestdio.h #includeconio.h void checkStack(int i) { if(i!=0) { printf(%d in %u address space\n,i,i); checkStack(i-1); } } int main() { int i=10; checkStack(i); getch(); return 0; } Looking at the address in the output terminal we

Re: [algogeeks] Re: Adobe Interview Question

2010-12-14 Thread Saurabh Koar
The function foo2 will be called iff the condition if(CD) evaluates to be true. Given that CD turns out to be true 75% times.So why the call to foo2 will be independent?? I think it is only the simple math.Correct me if I am wrong.. On 12/15/10, ankit sablok ankit4...@gmail.com wrote: what i

Re: [algogeeks] Re: Adobe Interview Question

2010-12-14 Thread Saurabh Koar
am wrong a detailed one thanx in advance On Wed, Dec 15, 2010 at 1:22 AM, Saurabh Koar saurabhkoar...@gmail.comwrote: The function foo2 will be called iff the condition if(CD) evaluates to be true. Given that CD turns out to be true 75% times.So why the call to foo2 will be independent

Re: [algogeeks] Re: Yahoo coding round question

2010-10-24 Thread Saurabh Koar
@Mohit: What I understand that in your solution the sum and product array contains the sum and products of contiguous sub-array starting from 0 to i (index of array A). What happens when the expected sub array starts form an index other than 0? -- You received this message because you are

Re: [algogeeks] Re: Adobe question

2010-10-22 Thread Saurabh Koar
@Mohit: Rajan clearly sais that array 2 contains all the elements of array1 + 1 extra element..Your example doesn't do so...By the way the method suhhested by Rajan is not universal.It is not necessary that array 2 will contain the same elements as array 1...XOR method will be the best... -- You

Re: [algogeeks] Yahoo coding round question

2010-10-20 Thread Saurabh Koar
@Kishen: Plz explain the complexity... On 10/20/10, Lily Aldrin lily.hi...@gmail.com wrote: @rahul the code doesn't fail for the case you gave. Please check. Also Kishen can you explain how is the complexity for two loops runninf in parallel equal to O(1). On Wed, Oct 20, 2010 at 3:06 PM,

Re: [algogeeks] Re: Modify Queue Data Structure which returns min in O(1) time.

2010-10-19 Thread Saurabh Koar
Why u people r going for implementing Queue using Stacks?? As Rahul Suggested in second thread can't this problem be solved by Priority Queue that uses Min Heap functions It clearly takes O(1) time for extracting minimum element.. -- Thanks Regards Saurabh Koar Final Year Under Graduate