[algogeeks] templates overloading
If we have templatized functions , return type becomes part of function signature ( which is not the case when we have normal non- templatized functions ) , So we can have two functions like these who differ only in return type templateclass T int foo(T) { cout this ; } templateclass T bool foo(T) { cout that ; } Questions is how do I call these functions. If I do like these int k = fooint(12) ; it cribbs that this call is ambiguos. How do we avoid this ambiguity ?? On googling it I could find one cast which solves this , but I could not understand it fully ((int(*)(char))foochar)('a'); Can some one explain in simple terms. -Manish -- 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] Starting Out
@abhijit : thanks a lot. @sharad kumar : no MIT 2007 batch.. -- Thanks and Regards Jayapriya Surendran -- 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] templates overloading
Out of curiosity why would you do something like this? Anil On Tue, May 25, 2010 at 12:45 PM, Modeling Expert cs.modelingexp...@gmail.com wrote: If we have templatized functions , return type becomes part of function signature ( which is not the case when we have normal non- templatized functions ) , So we can have two functions like these who differ only in return type templateclass T int foo(T) { cout this ; } templateclass T bool foo(T) { cout that ; } Questions is how do I call these functions. If I do like these int k = fooint(12) ; it cribbs that this call is ambiguos. How do we avoid this ambiguity ?? On googling it I could find one cast which solves this , but I could not understand it fully ((int(*)(char))foochar)('a'); Can some one explain in simple terms. -Manish -- 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.
Re: [algogeeks] templates overloading
let's break up that line you have in the end: int(*f)(char) = (int(*)(char))foochar ; f('a') ; it becomes clear that f has a return type of int. So the ambiguity is resolved... Anil On Tue, May 25, 2010 at 2:25 PM, Anil C R cr.a...@gmail.com wrote: Out of curiosity why would you do something like this? Anil On Tue, May 25, 2010 at 12:45 PM, Modeling Expert cs.modelingexp...@gmail.com wrote: If we have templatized functions , return type becomes part of function signature ( which is not the case when we have normal non- templatized functions ) , So we can have two functions like these who differ only in return type templateclass T int foo(T) { cout this ; } templateclass T bool foo(T) { cout that ; } Questions is how do I call these functions. If I do like these int k = fooint(12) ; it cribbs that this call is ambiguos. How do we avoid this ambiguity ?? On googling it I could find one cast which solves this , but I could not understand it fully ((int(*)(char))foochar)('a'); Can some one explain in simple terms. -Manish -- 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.
[algogeeks] most efficient way to calculate mode in an array of numbers
Hi, Can anyone tell me what is the most efficient algo to find the mode. Is it sorting and the then finding the max occurrence or can it be done in time less than O(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.
Re: [algogeeks] Re: another google telephone interview question
I think you don't need to use the median number as pivot. As long as you use different number to do partition, after log(k) times recursive, the N element will be sorted. On Sun, May 23, 2010 at 3:17 PM, Jagadish M jagadis...@gmail.com wrote: Further to my previous post, one question. Can the median be found in O(n) time without using extra memory? I am not familiar with the algorithms that find the median though I know the median can be found in O(n) time. This is important! I don't see how the standard algorithm for median finding can be tweaked to use only constant extra space. @Bharath: It's a nice algorithm, nevertheless :) -Jagadish http://www.cse.iitb.ac.in/~jagadishhttp://www.cse.iitb.ac.in/%7Ejagadish -- 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. -- Liu Yan -- 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: another google telephone interview question
how about using binary index tree?? On Tue, May 25, 2010 at 5:41 PM, liu yan ryu...@gmail.com wrote: I think you don't need to use the median number as pivot. As long as you use different number to do partition, after log(k) times recursive, the N element will be sorted. On Sun, May 23, 2010 at 3:17 PM, Jagadish M jagadis...@gmail.com wrote: Further to my previous post, one question. Can the median be found in O(n) time without using extra memory? I am not familiar with the algorithms that find the median though I know the median can be found in O(n) time. This is important! I don't see how the standard algorithm for median finding can be tweaked to use only constant extra space. @Bharath: It's a nice algorithm, nevertheless :) -Jagadish http://www.cse.iitb.ac.in/~jagadishhttp://www.cse.iitb.ac.in/%7Ejagadish -- 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. -- Liu Yan -- 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. -- yezhu malai vaasa venkataramana Govinda Govinda -- 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] most efficient way to calculate mode in an array of numbers
since we have to visit each value at least once we have to do at least O(n) steps so there cant be a solution in time less than o(n) but if the range of the values is limited we can use another array to count the number of occurrences of each value and the complexity would be: o(n) time o(max of the values) space On Tue, May 25, 2010 at 5:20 PM, Raj N rajn...@gmail.com wrote: Hi, Can anyone tell me what is the most efficient algo to find the mode. Is it sorting and the then finding the max occurrence or can it be done in time less than O(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.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.