[algogeeks] Re: Facebook Question

2011-12-22 Thread Gene
The simplest algorithm is probably to check each point against all others while maintaining a list of the top 3. Since 3 is a small number, you can just maintain the top 3 in sorted order by insertion. For a bigger K top-K you'd use a max heap. This can also be done in O(n log n) time by building

Re: [algogeeks] addition of two numbers without using logical or arithmetic operators

2011-12-22 Thread Karthikeyan V.B
Hi, *int sum(int num1,int num2) { for(int i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

Re: [algogeeks] Facebook Question

2011-12-22 Thread SAMM
@UTKARSH SRIVASTAV Give the implemetation logic instead of the name of the DS . -- 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 a

Re: [algogeeks] MCI

2011-12-22 Thread atul anand
wrong post on wrong group. On Thu, Dec 22, 2011 at 10:41 PM, aditi garg wrote: > Has anyone appeared fr Microsoft sales and marketing interview...if so > plz throw some light on it... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > T

Re: [algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-22 Thread atul anand
@Arun : yup ...rite... so i guess this will work..once pointer has been updated for parent node. there is no need of other point from children[i+1] to n. so adding one more loop at the end. for(i=0;ichildren[i],NULL); if(pre) { pre->childr

[algogeeks] MCI

2011-12-22 Thread aditi garg
Has anyone appeared fr Microsoft sales and marketing interview...if so plz throw some light on it... -- 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 gro

Re: [algogeeks] Re: Return index of first mismatch bracket "(" or ")"

2011-12-22 Thread atul anand
@Terence : got it :) :) ...inc/dec wont work On Thu, Dec 22, 2011 at 10:57 AM, Terence wrote: > Then what's your output for test case "()(()"? > > > On 2011-12-22 12:45, atul anand wrote: > > i guess there is no need of stack , we can take a variable say top; > > increment top when open bracket

Re: [algogeeks] Re: Return index of first mismatch bracket "(" or ")"

2011-12-22 Thread atul anand
got it :) On Thu, Dec 22, 2011 at 10:57 AM, Terence wrote: > Then what's your output for test case "()(()"? > > > On 2011-12-22 12:45, atul anand wrote: > > i guess there is no need of stack , we can take a variable say top; > > increment top when open bracket occur "(" and decrement when close

Re: [algogeeks] Re: Return index of first mismatch bracket "(" or ")"

2011-12-22 Thread atul anand
@venky : u call this code??? On Thu, Dec 22, 2011 at 7:44 PM, venky wrote: > #include#include#define maxsize 100 > struct stack{ int A[maxsize]; int top;}; struct stack s;void > push(int > index){ s.top++;if(s.top==maxsize) { > printf("cannot be pushed"); } > else{

[algogeeks] Re: Return index of first mismatch bracket "(" or ")"

2011-12-22 Thread venky
#include#include#define maxsize 100 struct stack{ int A[maxsize]; int top;}; struct stack s;void push(int index){ s.top++;if(s.top==maxsize) { printf("cannot be pushed"); } else{ s.A[s.top]=index; }} int pop(){ int a; a=s.top;

Re: [algogeeks] addition of two numbers without using logical or arithmetic operators

2011-12-22 Thread saurabh singh
Already discussed n times...nth discussion not required http://www.mail-archive.com/algogeeks@googlegroups.com/msg27861.html Check this link. On Thu, Dec 22, 2011 at 10:59 AM, Deepika Srinivisan < deepikasrini1...@gmail.com> wrote: > @:)) hello frnds >Can u pls help me out in writ

Re: [algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-22 Thread Arun Vishwanathan
@atul: can you explain what this is doing? for(i=0;ichildren[i],NULL); if(pre) { pre->children[i]=root; } } when u do tree reversal I see that child points to parent( basically direction reversed). Now if 1

Re: [algogeeks] Re: Return index of first mismatch bracket "(" or ")"

2011-12-22 Thread Terence
Then what's your output for test case "()(()"? On 2011-12-22 12:45, atul anand wrote: i guess there is no need of stack , we can take a variable say top; increment top when open bracket occur "(" and decrement when close bracket ")" occurs. keep track of first close bracket mismatch i.e when

[algogeeks] addition of two numbers without using logical or arithmetic operators

2011-12-22 Thread Deepika Srinivisan
@:)) hello frnds Can u pls help me out in writing a pgm how to add two numbers in C language without using both logical and arithmetic operators -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algo

Re: [algogeeks] Re: Dynamic programming question

2011-12-22 Thread Azhar Hussain
The first problem I mentioned is a similar problem. but the second one seems to be little difficult. where additional path we could go is up. - Azhar. On Thu, Dec 15, 2011 at 10:17 PM, Dheeraj Jain wrote: > http://www.geeksforgeeks.org/archives/14943 is a very similar problem. > > > On Thu, Dec

Re: [algogeeks] Re: Return index of first mismatch bracket "(" or ")"

2011-12-22 Thread Terence
And I think the comparing between first unmatched open/close bracket index is not needed. If we found an unmatched close bracket (ie. the stack is empty when encounter a close bracket), we could return current index immediately, since all open brackets before that position are matched and popp