Re: [algogeeks] probability
0.50 On Fri, Sep 7, 2012 at 6:05 PM, noname narayan.shiv...@gmail.com wrote: [image: -]14Answers http://www.careercup.com/question?id=14553727 What is the probability of being the answer correct for this question, when the answer is chosen randomly: a. 0.25 b. 0.60 c. 0.25 d. 0.50 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/nI1VXzZ6HDYJ. 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] what will be output for this program ?
64 32 16 32 16 32 64 32 On Fri, Jul 27, 2012 at 6:48 PM, Hraday Sharma hradaysha...@gmail.comwrote: #includestdio.h int main(){ printf(%d %d\n, 321, 320); printf(%d %d\n, 32-1, 32-0); printf(%d %d\n, 321, 320); printf(%d %d\n, 32-1, 32-0); return 0; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/oJogPmV-5msJ. 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] Re: microsoft interview
@dave:ur algo s nice:) On Thu, Sep 1, 2011 at 9:49 AM, Dave dave_and_da...@juno.com wrote: @Piyush: What does it do on 0 0 0 0 0 0 1 0 0 The output should be 1 0 0 1 0 0 1 1 1 Dave On Aug 31, 8:24 pm, Piyush Grover piyush4u.iit...@gmail.com wrote: What's wrong with this?? for( i = 0 ; i n ; ++i ) for( j = 0 ; j m ; ++j ) if( a[i][j] != 0 ) a[i][0] = a[0][j] = 1; for( i = 0 ; i n ; ++i ) for( j = 0 ; j m ; ++j ) if( a[i][0] + a[0][j] != 0 ) a[i][j] = 1; On Thu, Sep 1, 2011 at 5:45 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: Propagating a[0][0] as in my most recent post isn't correct. Gene is correct to have two flags that indicate whether the first row and/or the first column are to be filled with 1s. Dave On Aug 31, 7:01 pm, Dave dave_and_da...@juno.com wrote: @Icy: I forgot about a[0][0]. So I need to add a few lines at the end of my code, so that it becomes: for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][j] != 0 ) a[i][0] = a[0][j] = 1; for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][0] + a[0][j] != 0 ) a[i][j] = 1; // the following added to propogate a[0][0], if necessary. if( a[0][0] != 0 ) { for( i = 1 ; i n ; ++i ) a[i][0] = 1; for( j = 1 ; j m ; ++j ) a[0][j] = 1; } Dave On Aug 31, 5:12 pm, icy` vipe...@gmail.com wrote: Dave has a nice idea but I cant get it to work =/ [[1, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0]] original matrix [[1, 0, 1, 1], [1, 1, 1, 1], [0, 0, 1, 1]] dave's [[1, 1, 1, 1], [1, 1, 1, 1], [1, 0, 1, 1]] expected Maybe I converted it wrong. My method was basically the same as Anup's -- 1st pass fill rows and convert 1's to 2's. 2nd pass check for 2's and fill those columns. But complexity seems to be n*m*m + n*m*n = nm^2 + mn^2 which is about O(n^2 m^2) ?=/ I would like to get Dave's to work =P On Aug 31, 1:47 pm, siva viknesh sivavikne...@gmail.com wrote: @dave...additionally u ve to do this...checking the 1st row nd 1st column... if(a[0][0]) set both first row and first column; else for(i=1;in;i++) if(a[0][i]) set first row; else set first column; On Aug 31, 10:34 pm, siva viknesh sivavikne...@gmail.com wrote: dave s algo is nice :) On Aug 31, 10:09 pm, Dave dave_and_da...@juno.com wrote: @Ashima: Scan all but the first row and the first column. If there is a 1 in a row, set the first element of that row to 1. If there is a 1 in a column, set the first element of that column to zero. Now, set any element in all but the first row and the first column of the matrix that has a 1 it the first element of its row or a 1 in its first element of its colunn to 1. Dave On Aug 31, 12:02 pm, Ashima . ashima.b...@gmail.com wrote: @dave wats d logic behind ur code Ashima M.Sc.(Tech)Information Systems 4th year BITS Pilani Rajasthan On Wed, Aug 31, 2011 at 9:05 AM, Dave dave_and_da...@juno.com wrote: @Manish: for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][j] != 0 ) a[i][0] = a[0][j] = 1; for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][0] + a[0][j] != 0 ) a[i][j] = 1; Dave On Aug 31, 8:40 am, manish kapur manishkapur.n...@gmail.com wrote: Input is a matrix of size n x m of 0s and 1s. eg: 1 0 0 1 0 0 1 0 0 0 0 0 If a location has 1; make all the elements of that row and column = 1. eg 1 1 1 1 1 1 1 1 1 0 1 1 Solution should be with Time complexity = O(n*m) and O(1) extra space -- 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.-Hidequotedtext- - Show quoted text -- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to
[algogeeks]
can anyone explain the output of this program #includeiostream #includestdio.h #includeconio.h using namespace std; class date { int day,month,year; public: date(char *str); date(int m,int d,int y); date::date(); void show(); }; date::date(char *str) { scanf(str,*c*cd,month,day,year); } date::date(int m,int d,int y) { day=d; month=m; year=y; } date::date() { coutEnter month_day_year:; cinday; cinmonth; cinyear; } void date::show() { coutmonth'/'day'/'; coutyear'\n'; } main() { date sdate(11/1/1999); date idate(12,2,1998); date indate; sdate.show(); idate.show(); indate.show(); getch(); return 0; } output:1 Enter month_day_year:2 3 1 5060224/108/27 12/2/1998 3/2/1 -- 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] Re: Puzzle
consider the last two cases N married L not married L not married M married so now tak M and N compare it with first case M married N not married therfore,only m married On Sun, Aug 21, 2011 at 1:06 PM, Tushar Bindal tushicom...@gmail.comwrote: @arun if L is not married, then M must be married but if L is married then M can be married or not married, so if we say L is married to M, there is no problem in that On Sun, Aug 21, 2011 at 12:53 PM, Ravindra Singh Poonia ravindrasinghpoo...@gmail.com wrote: only M is married On Sat, Aug 20, 2011 at 11:24 PM, Puneet Chawla puneetchawla...@gmail.com wrote: only M is married. On Sat, Aug 20, 2011 at 7:53 PM, Arun Vishwanathan aaron.nar...@gmail.com wrote: @DK:if L is married to M according to you finally , then what does the third if then statement according to you mean when it is given that if L is not married then M is married? On Fri, Aug 19, 2011 at 10:35 PM, Dave dave_and_da...@juno.com wrote: @DK: What in the statement of the problem led you to believe that these were if-then statements? Dave On Aug 19, 3:15 pm, DK divyekap...@gmail.com wrote: Note that in the answer above, the table given is of the form: If condition is truethen what predicate is true ----- M - married N - not married N - married L - not married L - not married M - married -- DK http://gplus.to/divyekapoorhttp://twitter.com/divyekapoorhttp://www.divye.in -- 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. -- People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily. -- 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. -- With regards Puneet Chawla Computer Engineering Student NIT Kurukshetra -- 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. -- Thanks Regards, *Ravindra Singh* (RHCE) Mobile No. +91-9896949235 Mail ID- ravindrasinghpoo...@gmail.com Computer Engg. Dept. NIT Kurukshetra Haryana (INDIA) -- 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- 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] Google Question:Given a BST and a number, Find the closest node to that number in the BST.
@Abhishek:nice algo dude.. On Sat, Aug 20, 2011 at 12:56 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: Hey i tried it now and got to another solution O(log n) solution: 1. try searching for the number , if found,return the node, otherwise, you will ultimately reach a leaf node say 'nd' 2. Now the two candidates for the answer would be 1. TreeSuccessor(nd) 2. TreePredecessor(nd) Now compare the original number with these two and minimum would be the answer. (TreeSuccessor and TreePredecessor are the next and previous node resp. in the Inorder traversal of the tree.) On Sat, Aug 20, 2011 at 12:46 PM, Dipankar Patro dip10c...@gmail.comwrote: why traverse the whole tree? at each root keep the difference in a min_diff and min_ele. if the entered value is less root then move to left or right. repeat above two until whole tree is checked or min_diff becomes 0. pseudo code: min_diff = INF; // global variables min_ele = 0; find_min_diff(node *root, int num) { if (root == null) return; // update the difference if(abs(root-val - num) min_diff) { min_diff = abs(root-val - num); min_ele = root-val; } if ( min_diff == 0) return; // search is over // proceed to next element in tree which might be closer to the num if ( num root- val) find_min_ele(root-left, num); else find_min_ele(root-right, num); } ^^ Complexity : O(logn) On 20 August 2011 12:36, Abhishek Yadav algowithabhis...@gmail.comwrote: yes, the interviewer said that there is a solution in O(log n) On Sat, Aug 20, 2011 at 12:29 PM, sukran dhawan sukrandha...@gmail.comwrote: ur traversing the tree once so it shud be o(n).does the question demand 0(logn) ? On Sat, Aug 20, 2011 at 12:27 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: what would be the complexity of your solution O(n) or O(log n)..? On Sat, Aug 20, 2011 at 12:19 PM, sukran dhawan sukrandha...@gmail.com wrote: traverse bst inorder and each time u encounter a node find the difference between the element and given element in question . if the absolute difference is minimum after traversing the tree that is the element . u can getback the element using another element which keeps sign of the element so that original element can be obtained from diff On Sat, Aug 20, 2011 at 12:15 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: Given a BST and a number, Find the closest node to that number in the BST. Give an algorithm for that. Let there be binary search tree having nodes with values 12,34,64,23,64,25,76,6 and the number given is 28, then the answer would be 25 as it is the closest node. -- 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. -- 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. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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
Re: [algogeeks]
scanf takes input anything as well..but the output will be just a space On Sun, Aug 14, 2011 at 1:08 PM, Rajeshwar Patra rajeshwarpa...@gmail.comwrote: how does scanf takes the input ??? -- *Rajeshwar Patra,* *MCA final year,* *Nit Durgapur* -- 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. -- *Rajeshwar Patra,* *MCA final year,* *Nit Durgapur* -- 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] C Output
I think the address of string 5 located will be added with 1 and 2... On Sun, Aug 14, 2011 at 11:44 AM, Brijesh Upadhyay brijeshupadhyay...@gmail.com wrote: int main () { printf(%d,1+2+5); getch(); return 0; } what should it return and how..?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/2H3Gg6hLEQ0J. 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.