Re: [algogeeks] Query: Function returning void pointer
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 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Query: Function returning void pointer
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, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote: Can a function return a void pointer ? -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Find the element with more than n/k occurrences
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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: difference x
@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 use ur minimum intelligence to solve a problem.Otherwise(as pointed out by Swapnil some days ago) it really decreases the value of this group.More people will be active if they see new thought provoking problems.Also, u post problems and don't clear doubts of the members regarding ur problems.This is also bad habit. Hope u will understand.No offence intended. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: N companies merge
@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 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 group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Find The Looping Node
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 node-next-data=infinity u will say that the current node is causing the loop.Then restore the data of the linked list from the array.But I think more optimized algorithm is possible.Reply if you know more optimized way. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: difference x
@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 and I loved them.I jst requested u while posting if u review the ques carefully it will be helpful.I dint want to hurt u.If u r I m sorry.Bt still I will request u to post carefully.Lets finish this.And sorry once again. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Find the element with more than n/k occurrences
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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: maximize result
@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 calculate maxResult[0][n-1] now maxResult[i][i] will be num[i] DP is something like this: int calMax(i,j) { if there is an entry in maxResult[i][j] then return it otherwise { max= -(infinity) for(k=i;kj;k++) { t1=calMax(i,k); t2=calMax(k+1,j); val=t1 op_k t2; if(valmax) max=val; } maxresult[i][j]=val; return maxresult[i][j]; } } call int final_max_val=calMax(0,n-1); @juver++: Notify me if I am missing something. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: maximize result
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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon Interview Question about Linked Lists
@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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Find the element with more than n/k occurrences
@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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] bits groups
@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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] sort
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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] complete tree
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, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Minimum Triplet Distance
@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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon Interview Question about Linked Lists
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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon Interview Question about Linked Lists
@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) { 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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon Interview Question about Linked Lists
@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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: maximize result
@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 value of the total expression. Please notify me if I am missing something. On 12/19/10, juver++ avpostni...@gmail.com wrote: It's a classic dynamic programming problem. min[i][j] - minimum value for the subexpression starting at i-th position and ending at j-th, max[i][j] - the same but stores maximum value. Use these value to calculate value max[0][N-1], N - size of the expression. -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Minimum Triplet Distance
@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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: maximize result
@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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Minimum Triplet Distance
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 – y, y – z or z – x. Write a program to find minimum triplet distance. (means there are n1*n2*n3 number of possible triplets are possible...among all triplets which triplet has minimum distance...Give only distance, but not triplet elements). Your program must be as much efficient as possible. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Minimum Triplet Distance
@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 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 – y, y – z or z – x. Write a program to find minimum triplet distance. (means there are n1*n2*n3 number of possible triplets are possible...among all triplets which triplet has minimum distance...Give only distance, but not triplet elements). Your program must be as much efficient as possible. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Minimum Triplet Distance
@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 state that??or provide any link?? -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Minimum Triplet Distance
@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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] microsoft interview question
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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C aps ques
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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C output... ???
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 addresses each capable of holding an integer). On 12/14/10, Divesh Dixit dixit.coolfrog.div...@gmail.com wrote: #define SIZE 10 void size(int arr[SIZE]) { printf(size of array is:%d\n,sizeof(arr)); } int main() { int arr[SIZE]; size(arr); return 0; } the out put should be 40 considering 4 byte integer... but out put is only 4... how this is possible... and again if we modify it #define SIZE 10 int main() { int arr[SIZE]; printf(size of array is:%d\n,sizeof(arr)); return 0; } we are getting the desired output as 40 byte... thankyou in advance... -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] iTS aLL GOOGLE- iNTERVIEW
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 can get the ans... On 12/15/10, Ankur Khurana ankur.kkhur...@gmail.com wrote: mine did same job :) On Wed, Dec 15, 2010 at 12:41 AM, Anand anandut2...@gmail.com wrote: Below logic should tell us about the Machine Stack. let me know in case I am missing something. void check_for_stack(int a, int b) { unsigned int addr_1, addr_2; printf(%u %u\n, a, b); printf(0x%x 0x%x\n, a, b); if(a b) { printf(Machine Stack grows UP: Address keep decreasing); } else { printf(Machine stack grows down: Address Keep increasing); } } main() { int a,b; check_for_stack(a, b); } http://codepad.org/XGAbghDz On Tue, Dec 14, 2010 at 11:02 AM, bittu shashank7andr...@gmail.com wrote: How would you find out if a machine’s stack grows up or down in memory? can any one xplain wid program.. Regards Shashank Mani BIT Mesra -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adobe Interview Question
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 think is that the number of times foo2 being called is independent of the percentages given in the question it may be called 5000 times or 4999 times and continuinf in this fashion also none of the times as in every case there's 1/4 probability of AB and 3/4 of CD so as per me we cannot decide givn the percentage of success and failure any suggestions are always welcomed On Dec 15, 12:06 am, bittu shashank7andr...@gmail.com wrote: void foo1() { if(AB) Then {_/* */} else if(CD) then foo2() } How many time foo2() would get called given AB 25% of the times and CD 75% of the times and foo1() is called 5000 times although i had diff...solution..but i wants to confirm wid others..so hav a look Regards Shashank Mani BIT Mesra -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adobe Interview Question
@Sravan: Plz explain the logic.. On 12/15/10, Sravan Akepati sravan.akep...@gmail.com wrote: (1-0.25)* 0.75*5000 = 2812.5 On Wed, Dec 15, 2010 at 9:31 AM, ankit sablok ankit4...@gmail.com wrote: well i still believe that the calling of foo2 is independent plzzz suggest me the solution if i 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?? 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 think is that the number of times foo2 being called is independent of the percentages given in the question it may be called 5000 times or 4999 times and continuinf in this fashion also none of the times as in every case there's 1/4 probability of AB and 3/4 of CD so as per me we cannot decide givn the percentage of success and failure any suggestions are always welcomed On Dec 15, 12:06 am, bittu shashank7andr...@gmail.com wrote: void foo1() { if(AB) Then {_/* */} else if(CD) then foo2() } How many time foo2() would get called given AB 25% of the times and CD 75% of the times and foo1() is called 5000 times although i had diff...solution..but i wants to confirm wid others..so hav a look Regards Shashank Mani BIT Mesra -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Yahoo coding round question
@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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adobe question
@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 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Yahoo coding round question
@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, rahul patil rahul.deshmukhpa...@gmail.comwrote: On Wed, Oct 20, 2010 at 5:11 AM, Kishen Das kishen@gmail.com wrote: In the below code the jth and kth inner for loops can be run in parallel making them O(1) and the entire thing O(n). for ( i=0 to i=N-1 ) { for ( j = i to j = 0 ) { why till 0? if S=107 , P= 210 and array is 10, -3 , 2 , 105, 13 code will fail sum[j] += A[ i] product[j] *= A [ i] } for( k=0 to k= i ) if ( sum[k] == S and product[k] == P ) { Answer is the sub array A[k to i ] break } } Kishen On Tue, Oct 19, 2010 at 11:36 AM, abhishek singh iiita2007...@gmail.comwrote: @ Rahul patil ofcourse array may have negative or positive integers @ Kishen both O(n) and O(n logn) solutions was asked in this yahoo coding round question On Tue, Oct 19, 2010 at 1:28 PM, Abhishek Kumar Singh iiita2007...@gmail.com wrote: Given an array of length N. How will you find the minimum length contiguous sub - array of whose sum is S and whose product is P . Here S and P will be given to you. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- ABHISHEK KUMAR SINGH BTECH (INFORMATION TECHNOLOGY) IIIT ALLAHABAD 9956640538 -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Rahul Patil -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Modify Queue Data Structure which returns min in O(1) time.
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 Student Computer Science and Engineering NIT Durgapur India -- 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 group at http://groups.google.com/group/algogeeks?hl=en.