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] Soritng

2011-11-22 Thread Prem Krishna Chettri
This is a Great Question .. Answering My Opinion as Follows :- 1 Its QuickSort :- Coz we compare on the basis of pivotal element so , we are reducing half (or More ) of the total comparison by picking the the pivot as a bench mark. All rest of the sorting do the full element comparison. 2 Its

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] Query: Function returning void pointer

2011-11-22 Thread Akash Coder
ya void * malloc(void * ptr) since void * is generic pointer,it can converted to pointer of any type and vice versa 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

[algogeeks] Re: Time Complexity

2011-11-22 Thread Gene
Hi Atul, You're correct. I was commenting on the original poster's words I guess its NlogN for balanced tree as it is traversing N nodes for H times, which is not correct. The general result is that the run time will be O(N) for any balance rule where the ratio R of left to right subtree size

Re: [algogeeks] LCA of a Binary tree not a binary search tree

2011-11-22 Thread anshu mishra
first try to understand the sol then comment. it is for binary tree not for BST. On Mon, Nov 21, 2011 at 10:25 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: For BST it would be rather simpler. find the first node which lies in between the two. On Wed, Nov 16, 2011 at 1:44 PM, anshu

Re: [algogeeks] LCA of a Binary tree not a binary search tree

2011-11-22 Thread abhishek kumar
If you maintain the parent, it'll be a simple problem. Just go to the two nodes and then trace their parents till you reach the common node. On Tue, Nov 22, 2011 at 1:59 PM, anshu mishra anshumishra6...@gmail.comwrote: first try to understand the sol then comment. it is for binary tree not for

Re: [algogeeks] Re: NULL pointer

2011-11-22 Thread Ashish
In C language , the NULL is defined as int under stdio.h, has value 0, so you can do subtraction of NULL pointers, On Wed, Nov 16, 2011 at 6:57 AM, Dan dant...@aol.com wrote: Just FYI, You need to (and should always) be specific. Many languages have pointers. Many do not. Of those that

Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread DeVaNsH gUpTa
Yes Functions returning void pointers are generally used for generic programming. -- Thanks and Regards *Devansh Gupta* *B.Tech Third Year* *MNNIT, Allahabad* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] LCA of a Binary tree not a binary search tree

2011-11-22 Thread Piyush Grover
@anshu I was just replying to the earlier comments not to ur post. On Tue, Nov 22, 2011 at 2:23 PM, abhishek kumar abhi5...@gmail.com wrote: If you maintain the parent, it'll be a simple problem. Just go to the two nodes and then trace their parents till you reach the common node. On Tue,

[algogeeks] Re: function overloading query

2011-11-22 Thread MJ
Hi This type of function overloading works in c . Execute following code and it will call function fun as per the function parameter code snip-in - #includestdio.h void fun(const char *p) { printf(funsfsdafsf1\n); } void fun(char *P) { printf(fun2\n); } void

[algogeeks] An Array Problem

2011-11-22 Thread Ankuj Gupta
Input: A unsorted array of size n. Output: An array of size n. Relationship: elements of input array and output array have 1:1 correspondence. output[i] is equal to the input[j] (ji) which is smaller than input[i] and jth is nearest to ith ( i.e. first element which is smaller). If no such

[algogeeks] finding closest points

2011-11-22 Thread ganesha
Given a set of points in 2D space, how to find the k closest points for a given point, in time better than nlgn. -- 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

[algogeeks] Re: finding closest points

2011-11-22 Thread Dave
@Ganesha: You could use a max-heap of size k in time O(n log k), which is less than O(n log n) if k O(n). Dave On Nov 22, 8:56 am, ganesha suresh.iyenga...@gmail.com wrote: Given a set of points in 2D space, how to find the k closest points for a given point, in time better than nlgn. --

Re: [algogeeks] Re: array searching

2011-11-22 Thread himanshu kansal
@SAM: in your first step, where you are xoring the unique elements, you must be using some DS such as hashtable or something. so space complexity will be O(n). can someone reduces this O(n) space complexity.because it wont be a good approach if there are many elements in the

Re: [algogeeks] Re: finding closest points

2011-11-22 Thread Aamir Khan
On Tue, Nov 22, 2011 at 8:43 PM, Dave dave_and_da...@juno.com wrote: @Ganesha: You could use a max-heap of size k in time O(n log k), which is less than O(n log n) if k O(n). We can always ensure that k = n/2. If k = n/2 then the problem can be stated as, find m points farthest from the

Re: [algogeeks] Re: function overloading query

2011-11-22 Thread Jagannath Prasad Das
Run this one: #includestdio.h void fun(const char *p) { printf(const\n); } void fun(char *P) { printf(simple\n); } int main(void) { char str[] = funcheck; //const char str1[] = constcheck; fun(str); fun(str); } On Tue, Nov 22, 2011 at 7:13 PM, MJ mayurdj...@gmail.com wrote: Hi

Re: [algogeeks] Re: function overloading query

2011-11-22 Thread Jagannath Prasad Das
What this means compiler looks for closest possible match ,then other alternatives.In this func(char*) is executed if that is not there then func(const char*) is executed. Comment the func(char*) and check.There is no overloading in c as far i know. On Tue, Nov 22, 2011 at 10:11 PM, Jagannath

Re: [algogeeks] An Array Problem

2011-11-22 Thread Anup Ghatage
I can't think of a better than O(n^2) solution for this.. Any one got anything better? On Tue, Nov 22, 2011 at 8:23 PM, Ankuj Gupta ankuj2...@gmail.com wrote: Input: A unsorted array of size n. Output: An array of size n. Relationship: elements of input array and output array have 1:1

Re: [algogeeks] Re: Maximize Subsquare

2011-11-22 Thread kumar raja
@Vikas : what is the meaning of Allones function?? On 8 November 2011 15:13, Chunyuan Ge hhy...@gmail.com wrote: Say you define ur matrix in M then if (M(i,j) = 1) Sq(i,j) = min(Sq(i-1,j),Sq(i-1,j-1),Sq(i, j-1)) + 1 else Sq(i,j) = 0 On Tue, Nov 8, 2011 at 7:27 AM, vikas

Re: [algogeeks] An Array Problem

2011-11-22 Thread tech coder
here is an O(n) approach using a stack. problem can be stated as find the 1st smaller element on the right. put the first element in stack. take next element suppose num if this number is less than elements stored in stack, pop those elements , for these pooped elements num will be the

Re: [algogeeks] Re: finding closest points

2011-11-22 Thread tech coder
use a max heap of size k, On Tue, Nov 22, 2011 at 11:38 PM, Aamir Khan ak4u2...@gmail.com wrote: On Tue, Nov 22, 2011 at 8:43 PM, Dave dave_and_da...@juno.com wrote: @Ganesha: You could use a max-heap of size k in time O(n log k), which is less than O(n log n) if k O(n). We can always

Re: [algogeeks] An Array Problem

2011-11-22 Thread Aamir Khan
On Tue, Nov 22, 2011 at 11:50 PM, tech coder techcoderonw...@gmail.comwrote: here is an O(n) approach using a stack. problem can be stated as find the 1st smaller element on the right. put the first element in stack. take next element suppose num if this number is less than elements

[algogeeks] Re: finding closest points

2011-11-22 Thread Dave
@Aamir: But assuring that k = n/2 isn't the same thing as saying that k O(n). Note that if k = n/2, then O(n log k) = O(n log n). Dave On Nov 22, 10:38 am, Aamir Khan ak4u2...@gmail.com wrote: On Tue, Nov 22, 2011 at 8:43 PM, Dave dave_and_da...@juno.com wrote: @Ganesha: You could use a

Re: [algogeeks] An Array Problem

2011-11-22 Thread Anup Ghatage
What do you mean by if this number is less than elements stored in stack There have be N comparisons in the worst case. And that way, you have to do it for every element. So it will be governed by O(n^2) On Wed, Nov 23, 2011 at 12:50 AM, Aamir Khan ak4u2...@gmail.com wrote: On Tue, Nov

[algogeeks] Re: An Array Problem

2011-11-22 Thread Ankuj Gupta
One way could be sorting the array and also storing the original index along with that. After that we can search linearly in the array. On Nov 23, 5:40 am, Anup Ghatage ghat...@gmail.com wrote: What do you mean by  if this number is less than elements  stored in stack There have be N

[algogeeks] Re: Maximize Subsquare

2011-11-22 Thread DarkPrince
It means that the Borders of the mavximum rectangle should hav all 1s irrespective the elements inside the rectangles , it can be either 0 or 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] Re: Maximize Subsquare

2011-11-22 Thread DarkPrince
It means that the Borders of the mavximum rectangle should hav all 1s irrespective the elements inside the rectangles , it can be either 0 or 1 . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to