Re: [algogeeks] Re: Amazon

2011-07-19 Thread oppilas .
Thanks :) On Wed, Jul 20, 2011 at 10:55 AM, SAMM wrote: > This comes from the below > > n-n/2-n/2^2-..-n/2^k > > until n/2^k=1 > > Think from bits prospective > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this g

Re: [algogeeks] Re: Amazon

2011-07-19 Thread oppilas .
Nitish I am not able to understand. Can you please provide one or two examples? On Tue, Jul 19, 2011 at 1:40 PM, Nitish Garg wrote: > The algo gives the number of set bits in the number as pointed out by SAMMM > above. -- > You received this message because you are subscribed to the Google Groups

Re: [algogeeks] How to design Elevator Control system ?

2011-07-19 Thread oppilas .
I think discussing these question here would be a great idea. There is not such place where we can discuss such type of question( Atleast I don't know)+ It is very commonly asked in interviews. On Wed, Jul 20, 2011 at 1:59 AM, radha krishnan < radhakrishnance...@gmail.com> wrote: > i think we sho

Re: [algogeeks] Microsoft Interview Qn - Looping

2011-07-19 Thread oppilas .
Naveen indeed it's not infinite loop but it will print MS 2^31+1 times, right ? :) Change it so that it prints it 20 times. On Wed, Jul 20, 2011 at 7:39 AM, naveen ms wrote: > excuse me...can any explain y it goes to infinite loop.. > > with regards > naveen > > -- > You received this message be

Re: [algogeeks] Solve it

2011-07-19 Thread oppilas .
New constraint:- What if the array also contains positive and negative numbers? On Tue, Jul 19, 2011 at 4:36 PM, sagar pareek wrote: > ok ok ok thank you all > > > On Tue, Jul 19, 2011 at 4:35 PM, ankit sambyal wrote: > >> @Sagar: 13 is the correct answer. (6+4+3) >> >> -- >> You received this m

Re: [algogeeks] Amazon

2011-07-18 Thread oppilas .
Sagar can you please explain? http://ideone.com/a18nq On Tue, Jul 19, 2011 at 12:04 PM, sagar pareek wrote: > hey frnds :) > isn't the first one is zero knapsack problem? > > > On Tue, Jul 19, 2011 at 11:42 AM, SkRiPt KiDdIe wrote: > >> I think equal is referred as congruent. >> >> -- >> You re

Re: [algogeeks] Amazon

2011-07-18 Thread oppilas .
For 3rd, if we only want winner, Then 1110 players must lose. So total 1110 games. On Tue, Jul 19, 2011 at 10:37 AM, sagar pareek wrote: > 1. Let's say > > S=D=N > > repeat > > D=(floor)D/2; > > S=S-D; > > till D=0 > > From the above logic, figure out which algorithm is followed by 'S' > > 2. How

Re: [algogeeks] Re: Ever growing sorted linked list

2011-07-18 Thread oppilas .
Yes we can avoid integer comparison. But for jumping we will need to check whether the next node is null or not. So, depending upon the jump size, the number of comparison in worst case can be very large if our jump size is increasing exponentially. So, why not just compare with the next node in

Re: [algogeeks] Re: amazon

2011-07-13 Thread oppilas .
On Thu, Jul 14, 2011 at 10:18 AM, rogu3 wrote: > hey i got doubt regarding 3rd output, r n't u missing {{}{}} case?? > > Yes it will be. I guess can assume it safely :) > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussi

Re: [algogeeks] microsoft ques

2011-07-12 Thread oppilas .
The O(N) solution which I can think of. We need to divide the array in subarray's with division point being 0. Now, in those sub arrays, there are two cases: First- even number of -ve numbers, then max product of that subarray will be product of all elements. If it contains odd number, then take th

Re: [algogeeks] c doubt

2011-07-11 Thread oppilas .
On Mon, Jul 11, 2011 at 5:54 PM, Piyush Kapoor wrote: > Can anybody give a full explanation > > http://ideone.com/K1QmV > On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal wrote: > >> try to find out the binary representation of float value 5.2 >> >> >> On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta wro

Re: [algogeeks] C OUTPUT HELP

2011-07-11 Thread oppilas .
> *OUTPUT-* > 78 > 6 > > in this problem my problem is using printf and scanf as variable > names.they are functions in the stdio.h then how are they available for > variable name ??...generally what happens is that whenever we use some name > for the function and then use that name for some va

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
When the second string burns up, we have 45 min irrespective of the > burn rate. > > Even if you assume some different values of burn rate to make the > overall burn rate variable, you would get 45 min only. > > On Jul 9, 5:11 am, "oppilas ." wrote: >> You have 2

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
rate is 2/3m/minutes and for 30-60 it's 2m/minutes. If I burn it at 0, 30,60m position, then 30-60 meter part will be burnt in 7.5 minutes only. But 0-30 meter part will take 30/(4/3) i.e = 22.5 minutes. So, the complete string will burn in 22.5 minutes not 15. On Sun, Jul 10, 2011 at 1:26 A

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
rom either end and it burns completely in 1 hour. > > On Jul 9, 10:09 pm, "oppilas ." wrote: > > Yes, these solution are valid. But for them the burning rate of each > string > > must be constant. > > Each piece of string takes exactly an hour to burn, but the

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
Jul 9, 2011 at 8:57 PM, Dumanshu wrote: > @oppilas: > > light the first string at both ends and in the middle. So it will burn > completely in 15 min as the fire is advancing in 4 ways irrespective > of the burn rate. > when the first string is completely burnt, light the secon

Re: [algogeeks] Explanation

2011-07-09 Thread oppilas .
There are few bugs in your code. You are going to copy 10 characters in string str1, so the ideal size of str should be 10+1(for null character). Now when u used memcpy, then it perfectly copies initial 10 characters in str1. You can see it in you current output. But when u use %s for printing then

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-08 Thread oppilas .
minutes's worth of the second string will remain. Light the second > end of the second string. It will burn out in 15 more minutes., making > a total of 45 minutes. > > Dave > > On Jul 8, 7:11 pm, "oppilas ." wrote: > > You have 2 pieces of string of different

[algogeeks] String burn,measure time puzle

2011-07-08 Thread oppilas .
You have 2 pieces of string of different, unspecified length, and some matches. Each piece of string takes exactly an hour to burn, but the burn rate is not constant. . The strings have different burn rates, and of course you don't know the rates anyway. Using only the matches and the strings, mea

Re: [algogeeks] array or matrix problems...anyone?

2011-07-08 Thread oppilas .
What method did you used to multiply it efficiently? Any link for the same? On Fri, Jul 8, 2011 at 10:05 PM, Sriganesh Krishnan <2448...@gmail.com>wrote: > > ya...did that...anything else! > you know...like interview questions and stuff? > > On Fri, Jul 8, 2011 at 10:01 PM, shady wrote: > >> two

Re: [algogeeks] Re: Amazon

2011-07-07 Thread oppilas .
> step:- > 1) sort the array > 2) remove the smallest and largest element from arary. keep the smallest > elemnt in seperate queue(result) > 3) repeat the above untill the array is empty or it contains only it > contains only one element > 4) put the last element also in the queue (result) > > > eg

Re: [algogeeks] NVIDIA Q

2011-07-06 Thread oppilas .
Ok. So for differentiating objects, we have size 1. What will be size of following class:- class A{ int z; }; How does different objects gets differentiated in above case? On Wed, Jul 6, 2011 at 2:24 PM, durgaprasad k wrote: > The size will be 1 byte as there is nothing to look into the obj

[algogeeks] Complexity QuickSort

2011-07-05 Thread oppilas .
If u could find the (n/4)th element of an array in O(n) time, then what is the worst time complexity of quick sort algo if this algo is used to decide the pivot element. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, s

Re: [algogeeks] Re: VIRTUAL INHERITANCE

2011-07-05 Thread oppilas .
@T3rminal Then how would you explain size of Z in case of normal inheritance( sizeof(Z)=16 On Mon, Jul 4, 2011 at 4:08 AM, T3rminal wrote: > @abc abc > 4th class= two ints from X and Y classes + one int from base class( as > this class is shared ) + 2 virtual pointers of X and Y classes. > Accor

Re: [algogeeks] find output

2011-07-04 Thread oppilas .
On Mon, Jul 4, 2011 at 3:54 PM, amit the cool wrote: > main() > { > int i=0; > while(+(+i--)!=0) > Here the value passed of i is 0 only. So the next statement does not execute. But after using, I gets decremented to -1 > i-=i++; > printf("%d",i); > } > > output sud be 1 > bt it is -1; > why?? > >

Re: [algogeeks] RMQ doubt.

2011-07-01 Thread oppilas .
Sunny yes.. I want to implement RMQ solution of it in O(nlogk) not O(nlogn). On Fri, Jul 1, 2011 at 4:38 PM, sunny agrawal wrote: > is J-I = K for all queries? > > On Fri, Jul 1, 2011 at 4:08 PM, oppilas . wrote: > >> For finding maximum in a given range for an array , we n

[algogeeks] RMQ doubt.

2011-07-01 Thread oppilas .
For finding maximum in a given range for an array , we need to construct a seg tree of hight log(n). So, for n queries out time complexity will be O(nlogn). Now, if out query window size is known before hand, suppose j-i==K, how can I reduce the complexity to (nlogK for finding an minimum for a gi

Re: [algogeeks] Re: Constructing a Binary Search Tree from Post Order traversal-Possible or not

2011-06-30 Thread oppilas .
LST are less than root value. > > > On Thu, Jun 30, 2011 at 7:16 PM, Nishant wrote: > >> if BST contains integers then sort the postorder traversal which will >> give you inorder traversal... >> >> On Jun 30, 6:27 pm, "oppilas ." wrote: >> > Is

[algogeeks] Constructing a Binary Search Tree from Post Order traversal-Possible or not

2011-06-30 Thread oppilas .
Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give reason/counter examples. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread oppilas .
Sorry, didn't noticed that it was hard coded :) On Thu, Jun 30, 2011 at 12:13 AM, oppilas . wrote: > You code returns 1 for > >- input: > > >abab1abab1 > >output: > > >1 > >- input: > > >abababab1abab: > > >

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread oppilas .
, Anantha Krishnan < > ananthakrishnan@gmail.com> wrote: > >> I wish to say that we should not use any inbuilt functions. >> >> >> On Wed, Jun 29, 2011 at 11:43 PM, oppilas . wrote: >> >>> What I wanted to say that, it's a trivial question for a

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread oppilas .
se. I will try to fix it. Cheers :) On Wed, Jun 29, 2011 at 11:35 PM, oppilas . wrote: > http://ideone.com/YlGCC > > > On Wed, Jun 29, 2011 at 10:47 PM, Swathi wrote: > >> If you have any strong solution then write the pseudo code and explain >> your logic... please

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread oppilas .
http://ideone.com/YlGCC On Wed, Jun 29, 2011 at 10:47 PM, Swathi wrote: > If you have any strong solution then write the pseudo code and explain your > logic... please dont simply write like this.. it saves lot of time... code > and explain > > > On Wed, Jun 29, 2011 at

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread oppilas .
Why are we thinking of suffix tree in this case. Does not make sense. It the password is valid then it is of length between 5-12 only. Simple brute force approach will give decent time enough + we will not waste necessary memory and large line of code. On Wed, Jun 29, 2011 at 10:38 PM, Swathi wro

Re: [algogeeks] query

2011-06-29 Thread oppilas .
I have just copied ans pasted the code of OP. And changed " ". http://codepad.org/rBnx7z8V On Wed, Jun 29, 2011 at 8:17 PM, udit sharma wrote: > @Vaibhav: Sunny is also right bcz if u jst copy n paste d above code with > (/ *jp) it'll show an error... And the error is in printf statement. jst cut

Re: [algogeeks] query

2011-06-29 Thread oppilas .
Piyush the original code has double apostrophe( ' ) instead of inverted comma's. http://ideone.com/zPpGA On Wed, Jun 29, 2011 at 5:30 PM, Piyush Sinha wrote: > Its working fine.. > > > On Wed, Jun 29, 2011 at 5:26 PM, sunny agrawal wrote: > >> the error is in " " quotes, just rewrite them >> >> O

Re: [algogeeks] Amazon telephonic question

2011-06-28 Thread oppilas .
push(), pop() method as stack, and also has a getMinElement(). Require that getMinElement() is constant time but push()/pop() do not have to be constant time at first. Then for improvement, these three methods are all required to be constant time Define node as struct node{ int data; int cu

Re: [algogeeks] Re: O(n) Time is the problem. ..

2011-06-28 Thread oppilas .
o fetch O(N/4)+O(N/8). bites. So, overall time complexity is O(N). It would have been O(KN) where K is the number of bites in a integer only we would have fetched all the bites at least once. ~ Oppilas On Mon, Jun 27, 2011 at 8:38 AM, Dave wrote: > @Sanket: Yes. That is the first O(n) in my

Re: [algogeeks] Mouse Beer Puzzle

2011-06-28 Thread oppilas .
Andres yes, I also think so. We will end up using 5 mice. On Tue, Jun 28, 2011 at 3:54 PM, Anders Ma wrote: > I think the answer is 5. > To know which one is poisonous, you have to use one mouse. > > How to use 3 mice achieve this goal? > If all the 3 mice drink the poisonous beer, they will di

Re: [algogeeks] Mouse Beer Puzzle

2011-06-28 Thread oppilas .
Manish can you explain how? Please read the question carefully and explain accordingly. On Tue, Jun 28, 2011 at 3:40 PM, Manish Pathak wrote: > answer is 3 > > > -- > > Thanks and Regards, > > Manish Pathak ** > TimesJobs.com > > > -- > You received this message because you are subscribed to th

[algogeeks] Mouse Beer Puzzle

2011-06-28 Thread oppilas .
There are 6 beer bottle nd one is **not** poisoned. we have mice who will die within 14 hrs after drinkin poisned beer. In 24 hrs we have to find *nonpoisonous *beer bottle. How many no of mice we require to find out non poisoned bottle.? -- You received this message because you are subscribed to

Re: [algogeeks] Re: Product of N numbers - with Constraints

2011-06-28 Thread oppilas .
Anand, The code mentioned on your blog is wrong. http://codepad.org/n7YLkqaR On Mon, Jun 27, 2011 at 5:28 AM, Anand wrote: > > http://anandtechblog.blogspot.com/2010/09/given-array-of-numbers-replace-each.html > > > On Sun, Jun 26, 2011 at 10:12 AM, ross wrote: > >> @Dave: Very good solution..

[algogeeks] Printing unique rows.

2011-06-27 Thread oppilas .
Given a binary matrix of N X N of integers , you need to return only unique rows of binary arrays eg: 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 ans: 0 1 0 0 1 1 0 1 1 0 1 1 1 0 0 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this

Re: [algogeeks] Re: strings

2011-06-26 Thread oppilas .
anonymous see this http://ideone.com/TuNbS Can anyone tell me why gcc complier giving this warning prog.c:8: warning: implicit declaration of function ‘strlen’ On 6/26/11, anonymous procrastination wrote: > So finally what will be the solution? > Harshal's solution doesn't print the characters in

Re: [algogeeks] Re: Sort - Consecutive Array in O(n)

2011-06-25 Thread oppilas .
Divye Thanks for the link. Quoting the top answer from there. "Under the assumption numbers less than one are not allowed and there are no duplicates, there is a simple summation identity for this - the sum of numbers from 1 to m in increments of 1 is (m * (m + 1)) / 2. You can then sum the array

Re: [algogeeks] Re: char *arr and char arr[]

2011-06-25 Thread oppilas .
Thanks all :). On 6/25/11, Anantha Krishnan wrote: > When we declare *char *str="hello";* > > this "hello" will be stored in the read-only memory i.e *TEXT Segment*. > > so when we try to write the read-only memory by **str='w';* it will > throw *Segmentation > fault*. > > Obviously we must allo

[algogeeks] char *arr and char arr[]

2011-06-25 Thread oppilas .
I was reading about how char *arr is different from char arr[]. Now, as in char *arr="Pilani", arr stores the base address of the memory block reserved for Pilani. How, can I change the any character at that particular memory block? arr[0] ='T' gives error. #include using namespace std; int main()

Re: [algogeeks] Re: Sort - Consecutive Array in O(n)

2011-06-24 Thread oppilas .
Gene is correct :) Counter example {1, 2, 2, 5, 5} See method 3 here http://geeksforgeeks.org/?p=11516 On 6/25/11, Gene wrote: > Nice idea, but unfortunately doesn't work. The XOR only contains > parity information. So just pick two values in the range and a low > order bit where they're differe

Re: [algogeeks] Re: c query

2011-06-24 Thread oppilas .
Please see this. http://ideone.com/ZM74d I tried to print by directly giving 2[*arr] still it's giving null and 0.000. Can anyone think of a possible reason? On Fri, Jun 24, 2011 at 8:27 PM, rajeev bharshetty wrote: > @ T3rminal That is because the term is resolved as 2[*

Re: [algogeeks] Explain this.....

2011-06-24 Thread oppilas .
Sorry. Ignore the last message of mine. It does not belong to this thread. :) On Fri, Jun 24, 2011 at 8:37 PM, oppilas . wrote: > Please see this. > http://ideone.com/ZM74d > <http://ideone.com/ZM74d>I tried to print by directly giving 2[*arr] still > it's giving null

Re: [algogeeks] Explain this.....

2011-06-24 Thread oppilas .
Please see this. http://ideone.com/ZM74d I tried to print by directly giving 2[*arr] still it's giving null and 0.000. Can anyone think of a possible reason? On Fri, Jun 24, 2011 at 12:55 AM, richa mahajan wrote: > i think it ll be compiler dependent becoz comma acts as

Re: [algogeeks] O(n) Time is the problem. ..

2011-06-22 Thread oppilas .
Is the array sorted? In A[1..n], one number is missing from 0 to N. So, A[5]={--INF, 2,1,3,0} is a valid case? On Wed, Jun 22, 2011 at 11:51 PM, RollBack wrote: > An array A[1...n] contains all the integers from 0 to n except for one > number which is > missing. In this problem, we cannot access

Fwd: [algogeeks] Re: strings

2011-06-22 Thread oppilas .
May be I didn't understood your logic. According to original question for I/P kapilra O/P --kaapilr.. Now, -what if we create a binary tree with root as the first element of the string and if the next character is equal then place it to left else place it to right. Similar comparison will be d

Re: [algogeeks] Re: strings

2011-06-22 Thread oppilas .
No, it will not work. We don't have to print all the characters in sorted order. On Thu, Jun 23, 2011 at 12:19 AM, snehi jain wrote: > what if we create a binary tree with root as the first element of the > string and if the next character is equal then place it to left else place > it to right.

Re: [algogeeks] Re: sort the array

2011-06-22 Thread oppilas .
On Wed, Jun 22, 2011 at 8:38 PM, oppilas . wrote: > > > On Wed, Jun 22, 2011 at 8:20 PM, Navneet Gupta wrote: > >> Let the array elements be 2,3,5,10 & 1,4,8,12. >> >> Have two index variables m and n. Intially m will point to 2 and n to 1. >> >> 1.

Re: [algogeeks] Re: sort the array

2011-06-22 Thread oppilas .
On Wed, Jun 22, 2011 at 8:20 PM, Navneet Gupta wrote: > Let the array elements be 2,3,5,10 & 1,4,8,12. > > Have two index variables m and n. Intially m will point to 2 and n to 1. > > 1. Compare the elements in m and n. > 2. If elem[m] > elem[n] swap, increment n > *I think it should be increment

Re: [algogeeks] Explain this.....

2011-06-22 Thread oppilas .
Yes, that I know, but why last argument is printing 100 instead of 99? On Wed, Jun 22, 2011 at 7:50 PM, Piyush Sinha wrote: > the arguments are passed from right to left in a function... > > initially ptr is pointing to location of 98 (i =1) > > the last argument ++ptr makes it point to 99 theref

Re: [algogeeks] Explain this.....

2011-06-22 Thread oppilas .
Yes, for me also it's coming out 99 If I do it orally but on compiling it's coming 100. http://codepad.org/KKLEXY45 On Wed, Jun 22, 2011 at 7:39 PM, Piyush Sinha wrote: > r u sure the last output is also 100..for me its coming 99 > > On 6/22/11, udit sharma wrote: > > #include > > int main() >

Re: [algogeeks] نيك عربي وصراخ من الطيز بقوه

2011-06-22 Thread oppilas .
+1 2011/6/22 Naveen Kumar > ban him moderators... > > 2011/6/22 asxsa asxsa <3.asxs...@gmail.com> > >> >> >> >> >> [image: http://i20.servimg.com/u/f20/09/00/39/91/010.png] >> >> >> [im

Re: [algogeeks] Binary Tree

2011-06-21 Thread oppilas .
Sunny, Can but can we modify this code to get the *node X and node Y*?. On Wed, Jun 22, 2011 at 8:32 AM, Anantha Krishnan < ananthakrishnan@gmail.com> wrote: > @sunny agrawal > *Thanks a lot.* > *Great code. I got the logic now.Thanks again.* > * > * > Thanks & Regards, > Anantha Krishnan >

Re: [algogeeks] Re: finding vlaue of nCr

2011-06-21 Thread oppilas .
@Wladmir. If you see carefully,then it is quite obvious that product of n consecutive number will be divisible by n!. 3 must be a divisor of at least one number out of three consecutive number.( because each multiple of 3 lies, 3 number ahead of previous one.) Similarly, we can argue for ith numbe

Re: [algogeeks] Re: Find an element which is not present?

2011-06-21 Thread oppilas .
ple input and corresponding o/p. On Tue, Jun 21, 2011 at 11:55 PM, oppilas . wrote: > @Sanket, > This is one of the possible solution but it does not take into account. > > On 6/21/11, sanket dhopeshwarkar wrote: > > 1. find the min , max, and sum of all elements in array(say z) - o(n)

Re: [algogeeks] Re: Find an element which is not present?

2011-06-21 Thread oppilas .
@Sanket, This is one of the possible solution but it does not take into account. On 6/21/11, sanket dhopeshwarkar wrote: > 1. find the min , max, and sum of all elements in array(say z) - o(n) > 2. find x= sum(1..min) and y = sum(1..max) > 3. ans = y-(x-min) -z >if(ans ==0) return (min-1)

Re: [algogeeks] Minimum draws for correct labels

2011-06-20 Thread oppilas .
Yes. One draw only. As all the box are incorrectly labeled so, box BW willl either contain 2Black or 2 white balls. We pick one ball from BW box. If it's white( it contains WW ball), then as the box label WW does not contain while, it can either have BB or BW ball. But it must have BB ball inside i

Re: [algogeeks] Re: spoj problem chairs

2011-06-20 Thread oppilas .
I think you have not read the question carefully. Please read it again and try to ans for small values of n,k first. for k=1, answer will be always 1. On Mon, Jun 20, 2011 at 6:31 PM, saurabh singh wrote: > O.K can anyone suggest the combinatorial solution.I thought it this way- > Assume k chair

Re: [algogeeks] Re: output....

2011-06-20 Thread oppilas .
out of the for loop.. > > hence prints 6.. > > > On Mon, Jun 20, 2011 at 12:05 AM, Oppilas wrote: > >> Sanjay, >> Whenever we encounter a break statement does not it means to take the >> program counter outside of the current loop. >> I am confused

[algogeeks] Re: output....

2011-06-20 Thread Oppilas
Sanjay, Whenever we encounter a break statement does not it means to take the program counter outside of the current loop. I am confused a little bit. Someone please clarify. See the following program #include #include int main(){ int t=4; for(int i=0;i<5;i++){ if(1){ if(t==6)

Re: [algogeeks] Sum to K problem

2011-06-19 Thread oppilas .
Vaibhav, We are not finding two numbers with sum "X". Here we are talking about subset. :) @Navneet Please see this link http://www-ti.informatik.uni-tuebingen.de/~reinhard/krypto/English/4.5.1.e.html PS: You might have seen it before. In that case ignore it. ~ Oppilas On Mon, Jun 2

Re: [algogeeks] Sum to K problem

2011-06-19 Thread oppilas .
I think its a NP problem. The solution complexity can go up O(2^N) in worst case. On Mon, Jun 20, 2011 at 11:55 AM, Navneet Gupta wrote: > Given a set of integers , find a set of numbers such that they sum to a > given number k . > Notice the set of numbers can have 2 or more than 2 numbers. > >