Re: [algogeeks] Re: matrix finding immediate neighour

2011-08-26 Thread tech coder
@ shashank and all can we an approach that take less time than O(N^2). I mean not in O(N ) or nlogn but n^2 some optimiation On Thu, Aug 25, 2011 at 8:43 PM, WgpShashan) k shashank7andr...@gmail.com wrote: @Sharvan ..Yes We Can do That and yes i forgot that intead of locals.add(a[i][j]) , we

[algogeeks] Post-Increment simple program - Aptitude probelm

2011-08-26 Thread Suraj Fale
Hey guys.. I know in this group all geeky stuffs goes on... but following lines of code i foind it intresting and thah y wants ot sahre it with you all. Its very basic but some may of you may not know, int main() { int i=0; if(i++) printf(Hello); else printf(Bye); return 0; } /*

[algogeeks] DBMS Q

2011-08-26 Thread Vijay Khandar
ER-diagram is given and asking for min and max table. Can anyone Explain me .. -- 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

Re: [algogeeks] Post-Increment simple program - Aptitude probelm

2011-08-26 Thread Vijay Khandar
O\P-Bye I think so.plz explain how its hello On Fri, Aug 26, 2011 at 12:12 PM, Suraj Fale surajfa...@gmail.com wrote: Hey guys.. I know in this group all geeky stuffs goes on... but following lines of code i foind it intresting and thah y wants ot sahre it with you all. Its very

[algogeeks] chanege in immutable string

2011-08-26 Thread tech coder
in java a tring object is immutable but in following code String s=java; s+=c c++; System.out.print(s); the output is javac c++ why this is so -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: Adobe Interview - 20/08/2011

2011-08-26 Thread vikas
think in 2d and I assume that both the sphere are touching each other. it should be simple 2d maths now :) On Aug 25, 8:32 pm, rakesh kumar rockey.rav...@gmail.com wrote: Could you explain the solution for shere problem On Thu, Aug 25, 2011 at 3:49 PM, vikas vikas.rastogi2...@gmail.com

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread Prem Krishna Chettri
Its true that in Java String are immutable. Even in the code given its immutable.. Its actually the code executed like this.. String s=java; // S holds to java. s+=c c++; // Here S = S + c c++ Java + c c++ which is now assigned to the new variable which here is s itself.

[algogeeks] What is the output and how ???

2011-08-26 Thread SAMMM
includestdio.h void fun(int); typedef int (*pf) (int, int); int proc(pf, int, int); int main() { int a=3; fun(a); return 0; } void fun(int n) { if(n 0) { fun(--n); printf(%d,, n); fun(--n); } } -- You received this message because you are

Re: [algogeeks] elitmus test

2011-08-26 Thread ROHIT SINGHAL
its been a while tat i had gave test bt i remebr quant was full of geometry application so clear ur concept for geometry. and in logical they give this kinda alphanumeric prob. my advice in quant and logical correct 3-4 questions out of 20 each u gonna get a gud percentile. for sure. On Fri, Aug

Re: [algogeeks] Post-Increment simple program - Aptitude probelm

2011-08-26 Thread Suraj Fale
Thats correct it will print 'Bye'... i just said Hello so everyone will try to compile it and ask questions like you. Thanks for showing intrest. Btw you can share such aptitude questions if u have On Fri, Aug 26, 2011 at 12:15 PM, Vijay Khandar vijaykhand...@gmail.comwrote: O\P-Bye I

Re: [algogeeks] What is the output and how ???

2011-08-26 Thread Vijay Khandar
O\P= 1 2 1 3 1 2 1 is it correct? On Fri, Aug 26, 2011 at 12:23 PM, SAMMM somnath.nit...@gmail.com wrote: includestdio.h void fun(int); typedef int (*pf) (int, int); int proc(pf, int, int); int main() { int a=3; fun(a); return 0; } void fun(int n) { if(n 0) {

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread siddharam suresh
as per my knowledge, in java String s=java; // S holds to java. s+=c c++; // now s is pointing to string javac c++ not the appended string (java+c c++) // strcat and append syntactically(o/p strings) are same but wrt to memory they differ Thank you, Siddharam On Fri, Aug 26, 2011 at

Re: [algogeeks] C Trick

2011-08-26 Thread saipraneeth
ar[0]=a; ar[1]=b; printf(largest %d,ar[((a-b)31)0x1]); On Wed, Aug 24, 2011 at 11:20 PM, kranthi kumar damarlakran...@gmail.comwrote: @priyanka raju, Good solution... -- Regards: --- D Kranthi kumar Computer Science Engg. IIT Madras. -- You received this

[algogeeks] Re: stack using bst

2011-08-26 Thread Dumanshu
So, in short you are using a BST and a FIFO linked list. Whereas, a Stack is actually a LIFO linked list. Am i right? On Aug 25, 11:37 pm, Don dondod...@gmail.com wrote: You will have to keep two pointers, one to the root of the tree and one to the head of the FIFO linked list. To push, insert

[algogeeks] Re: What is the output and how ???

2011-08-26 Thread SAMMM
The O/P is 0,1,2,0, But how -- 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

Re: [algogeeks] Re: What is the output and how ???

2011-08-26 Thread Suraj Fale
o/p:- 0,1,2,0.. iIts simple stack concepts... during each recursive call it will goes on to store 2,1,0 and then *it will print 0* . call it agin with -1 then ... its false then* it will print 1* and again it will become 0... its false so it takes value from stack which is 2.. so *it will

[algogeeks] Re: shortest swapping rows

2011-08-26 Thread Algo'nAlgo
Its O(n*n) algo.. so you have to just iterate n times.. please take an exampla and solve it.. u'll get to know urself :) On Aug 19, 3:14 am, Prakash D cegprak...@gmail.com wrote: hey, thanks.. but if it needs many iteration, then we've to check each time whether the array is sorted.. is there

Re: [algogeeks] Re: C Trick

2011-08-26 Thread rajesh singarapu
abs function itself has a condition?? I think it is not that good solution. On Wed, Aug 24, 2011 at 6:33 PM, priyanka raju priyark...@gmail.com wrote: int a,b,max,min; max=(a+b+abs(a-b))/2; min=(a+b-abs(a-b))/2; -- cheers priyanka -- You received this message because you are

Re: [algogeeks] Re: What is the output and how ???

2011-08-26 Thread kARTHIK R
Here is a simpler way to understand. fun(0) = prints nothing fun(1) = f(0) + print 0 + fun(-1) = 0 fun(2) = fun(1) + print 1 + fun (0) = 0 1 fun(3) = fun(2) + print 2 + fun(1) = 0 1 2 0 Karthik R, RD Engineer, Tejas Networks. On Fri, Aug 26, 2011 at 1:02 PM, Suraj Fale surajfa...@gmail.com

[algogeeks] inorder predecessor

2011-08-26 Thread Vikram Singh
i figured out algo to find the inorder predecessor of a bst without using parent pointer... just wanna confirm if its missing any case if the left child(subtree) of node exist, then predecessor ll be the max value in the left subtree. else predecessor ll be one of the ancestor in this

Re: [algogeeks] elitmus test

2011-08-26 Thread Deepak Kanojia
@Rohit. Could you please tell wht was the marking scheme of the test? -- 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

Re: [algogeeks] Re: Suggestion

2011-08-26 Thread Suraj Fale
A book by 'Yashwant Kanetkar' On Fri, Aug 26, 2011 at 9:03 AM, Navneet navneetn...@gmail.com wrote: Ankit, i would also like to mention Mark Allan Weiss book on Data Structures. Available in both C and C++ (different books) On Aug 25, 3:59 pm, Abhishek mailatabhishekgu...@gmail.com wrote:

[algogeeks] Playdom Interview ques

2011-08-26 Thread Navneet Gupta
Posting few questions which Playdom asked a friend of mine in telephonic interviews. He had to write code in all cases. 1. Print m*n matrix in spiral form. Modify to make it iterative. 2. Print level order traversal or tree along with level information. Tree need not be complete a 1 b c

[algogeeks] is it possible to access data from memory location 0?

2011-08-26 Thread siddharam suresh
Thank you, Siddharam -- 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,

Re: [algogeeks] Playdom Interview ques

2011-08-26 Thread Neha Singh
1. int top,bottom,left,right,size; void printTop(int arr[][size]) { int i=top,j; for(j=left;j=right;j++) printf(%d ,arr[i][j]); } void printBottom(int arr[][size]) { int i=bottom,j; for(j=right;j=left;j--) printf(%d ,arr[i][j]); } void printLeft(int arr[][size]) {

Re: [algogeeks] Playdom Interview ques

2011-08-26 Thread Neha Singh
for ques 3: ]1) If right subtree of node is not NULL, then succ lies in right subtree. Do following. Go to right subtree and return the node with minimum key value in right subtree. 2) If right sbtree of node is NULL, then succ is one of the ancestors. Do following. Travel up using the parent

[algogeeks] Re: Playdom Interview ques

2011-08-26 Thread Navneet Gupta
One thing i should mention in ques3, you have the parent pointer of node. (so left, right and parent pointers can be used) On Fri, Aug 26, 2011 at 3:22 PM, Navneet Gupta navneetn...@gmail.comwrote: Posting few questions which Playdom asked a friend of mine in telephonic interviews. He had to

Re: [algogeeks] Re: Playdom Interview ques

2011-08-26 Thread Neha Singh
For ques 2: ./*Function to print level order traversal of tree*/ printLevelorder(tree) for d = 1 to height(tree) { printGivenLevel(tree, d); printf( %d\n,d); } /*Function to print all nodes at a given level*/ printGivenLevel(tree, level) if tree is NULL then return; if level is

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread Neha Singh
@tech coder: When u execute : s+=c c++; a new string object is created with the value of s appended with c c++. Now s is made to hold the reference of this new string object. Thus the older string object is not modified, but a new string string object is created. -- You received this message

Re: [algogeeks] inorder predecessor

2011-08-26 Thread sukran dhawan
is it not possible to traverse tree in order and store in array. then figure out the element and print the previous element? On Fri, Aug 26, 2011 at 2:04 PM, Vikram Singh singhvikram...@gmail.comwrote: i figured out algo to find the inorder predecessor of a bst without using parent pointer...

Re: [algogeeks] Re: Reverse dutch flag problem

2011-08-26 Thread sukran dhawan
count no of 0s,1s and 2s.fill first 0s followed by 1s den 2s :) On Thu, Aug 25, 2011 at 11:37 PM, icy` vipe...@gmail.com wrote: not enough information, imo. Tell me more about the given string... is the string made up of consecutive integers/characters ? Are there always the same number of

[algogeeks] Re: inorder predecessor

2011-08-26 Thread Vikram Singh
ya thats one option but that gives ans in O(n), requires additional memory... and unnecessarily finds for all which is not required... my sol doesnt require any extra space i.e. in O(1) space... and also in O(log n) time... tell if dere is any missing case On Aug 26, 4:58 pm, sukran dhawan

Re: [algogeeks] Re: inorder predecessor

2011-08-26 Thread Sanjay Rajpal
Vikram : will u plz elaborate more on ur solution ? Sanju :) On Fri, Aug 26, 2011 at 5:24 AM, Vikram Singh singhvikram...@gmail.comwrote: ya thats one option but that gives ans in O(n), requires additional memory... and unnecessarily finds for all which is not required... my sol doesnt

Re: [algogeeks] Re: inorder predecessor

2011-08-26 Thread sukran dhawan
hmmm k On Fri, Aug 26, 2011 at 5:54 PM, Vikram Singh singhvikram...@gmail.comwrote: ya thats one option but that gives ans in O(n), requires additional memory... and unnecessarily finds for all which is not required... my sol doesnt require any extra space i.e. in O(1) space... and also in

[algogeeks] Re: inorder predecessor

2011-08-26 Thread Vikram Singh
i m writing just a pseudocode... // root is the root of treeand node is the node whose predecessor is to be found predecessor(root, node) { parent=NULL; if(root==NULL) return ; if(node-left!=NULL) { // find max value in left subtree... } else { while(root!=NULL

Re: [algogeeks] Re: inorder predecessor

2011-08-26 Thread Sanjay Rajpal
got it Vikram :) Sanju :) On Fri, Aug 26, 2011 at 5:43 AM, Vikram Singh singhvikram...@gmail.comwrote: i m writing just a pseudocode... // root is the root of treeand node is the node whose predecessor is to be found predecessor(root, node) { parent=NULL; if(root==NULL)

[algogeeks] Re: Playdom Interview ques

2011-08-26 Thread Navneet
@Neha, For your solution of 1, you needed to take m*n matrix into account. Though i think your approach should work fine even in that case. Function signature will change. For 3rd solution, the corner cases actually little non-trivial while writing code(need to consider root, root with no right

[algogeeks] Re: Playdom Interview ques

2011-08-26 Thread Navneet
Also for ques 1, instead of having four auxiliary functions, you can have a variable flag for rows and cols functions being passed as param and reduce the number to two. On Aug 26, 6:07 pm, Navneet navneetn...@gmail.com wrote: @Neha, For your solution of 1, you needed to take m*n matrix into

Re: [algogeeks] Re: puzzle

2011-08-26 Thread Himanshu Srivastava
lol :P On Wed, Aug 10, 2011 at 11:35 PM, $hr! k@nth srithb...@gmail.com wrote: Tie the rope at the top of the tower Climb down with the help of the rope up to 100 mt peg possItion Tie the rope to that peg, Climb up to the top of the tower with that rope. Now release the rope at the top and

Re: [algogeeks] Re: Suggestion

2011-08-26 Thread saurabh singh
Yayashwant kanitekar and deepali srivastava are great books If you find all the mistakes that they have made you have learned DS(and coding style) quite well.:p On Fri, Aug 26, 2011 at 2:44 PM, Suraj Fale surajfa...@gmail.com wrote: A book by 'Yashwant Kanetkar' On Fri, Aug 26, 2011

Re: [algogeeks] Re: puzzle

2011-08-26 Thread Naren s
varun: can u explain it little further.. On Wed, Aug 10, 2011 at 7:49 PM, varun pahwa varunpahwa2...@gmail.comwrote: make two ropes 50m and 100 meter. make a loop kind of thing with that now you have two 50 mtr ropes so get down to 100 mtr point and tie loop rope in downward now cut the loop

Re: [algogeeks] is it possible to access data from memory location 0?

2011-08-26 Thread SANDEEP CHUGH
no it results in segmentation fault On Fri, Aug 26, 2011 at 3:48 PM, siddharam suresh siddharam@gmail.comwrote: Thank you, Siddharam -- 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] is it possible to access data from memory location 0?

2011-08-26 Thread siddharam suresh
but its its valid address right Thank you, Sid. On Fri, Aug 26, 2011 at 8:16 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: no it results in segmentation fault On Fri, Aug 26, 2011 at 3:48 PM, siddharam suresh siddharam@gmail.com wrote: Thank you, Siddharam -- You

Re: [algogeeks] Re: Suggestion

2011-08-26 Thread sukran dhawan
wat are u tying to say :P ? is that a good book or wat ? On Fri, Aug 26, 2011 at 7:55 PM, saurabh singh saurab...@gmail.com wrote: Yayashwant kanitekar and deepali srivastava are great books If you find all the mistakes that they have made you have learned DS(and coding style) quite

Re: [algogeeks] is it possible to access data from memory location 0?

2011-08-26 Thread UTKARSH SRIVASTAV
i think it is reserved for system functions and you are not allowed to work as your program is not alloted that area if somehow your program is allowed that area there will be no segmentation fault On Fri, Aug 26, 2011 at 7:57 AM, siddharam suresh siddharam@gmail.comwrote: but its its valid

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread tech coder
thanks to all got it On Fri, Aug 26, 2011 at 4:54 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: @tech coder: When u execute : s+=c c++; a new string object is created with the value of s appended with c c++. Now s is made to hold the reference of this new string object. Thus the older

[algogeeks] Tejas Network Placement Process!!!

2011-08-26 Thread rohit
Please share Process and experience of tejas Network for software profile. Thanks -- 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] Re: Given a number, return the least prime greater than number

2011-08-26 Thread Don
Usually that is done before run time and hard coded into the hash function. But for numbers in the range you are talking about, a sieve would work. However trial division should not take long either, if you just need to do it once when the hash table is created. Don On Aug 25, 10:18 pm, Navneet

Re: [algogeeks] is it possible to access data from memory location 0?

2011-08-26 Thread saurabh singh
0 is reserved as the address which can't be referenccd On Fri, Aug 26, 2011 at 9:08 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: i think it is reserved for system functions and you are not allowed to work as your program is not alloted that area if somehow your program is allowed

[algogeeks] Re: Find the non-duplicate element in sorted array in O(n) time

2011-08-26 Thread Don
After working on it quite a bit I got an O(log n) algorithm working. For small cases (size 10) it sequentially finds the solution. For larger cases it uses a binary search: Starting at the midpoint, find the left and the right ends of the region with values equal to the value at the midpoint.

[algogeeks] Regarding Sandisk

2011-08-26 Thread NAGARAJAN SIVARAMAN
Do anyone have ideas regarding Sandisk technical and interview questions...?? or any link to refer..?? Thanks in advance -- 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

Re: [algogeeks] unsorted array problem

2011-08-26 Thread tech coder
it can be done in O(N) by using XOR ing the elements 1: Xor all the elemnts since those elemnts that even freq will nullify each other we get number taht will tell in which the two required number differ. 2: divide the array in two sets on the basis of bit in which numbers differ 3:1 element

[algogeeks] array sum

2011-08-26 Thread sukhmeet singh
how to divide an integer array into 2 sub-arrays and make their averages equal? array is unsorted and we can also take any numbers and the numbers in the array need not be contiguous in the original array. how many total such array's are possible. Output them -- You received this message because

[algogeeks] maximum XOR

2011-08-26 Thread sukhmeet singh
Given n unsigned integer, output 2 integers which has the maximum result after XOR -- 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] microsoft

2011-08-26 Thread rahul sharma
hi guys...microsoft is coming to our campus..plz nyone tell their recruitment procedure..n give me their previous xams question if nyone has...but please tell me their selection procedure n roundscuming after 2 days.plz reply soon.n tell me the subjects to crack

[algogeeks] Re: What is the output and how ???

2011-08-26 Thread rahul sharma
yeah...just clear concept of recursion...its simple form test ur c skilss..(function.) On Aug 26, 1:22 pm, kARTHIK R k4rth...@gmail.com wrote: Here is a simpler way to understand. fun(0) = prints nothing fun(1) = f(0) + print 0 + fun(-1) = 0 fun(2) = fun(1) + print 1 + fun (0) = 0 1 fun(3)

Re: [algogeeks] maximum XOR

2011-08-26 Thread Neha Singh
Sort the nos., which can be done in O(nlogn) Now the 1st and the last integers are the required integers. -- 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

Re: [algogeeks] microsoft

2011-08-26 Thread Neha Gupta
college? -- 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

Re: [algogeeks] maximum XOR

2011-08-26 Thread jai gupta
@Neha take 42, 21 and 1 42 ^ 1 =43 while 42 ^21 =63 On Fri, Aug 26, 2011 at 10:28 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote: Sort the nos., which can be done in O(nlogn) Now the 1st and the last integers are the required integers. -- You received this message because you are

[algogeeks] Re: microsoft

2011-08-26 Thread rahul sharma
thaparit is 100% yet sure.but it is 99% sure.i wana prepare early... On Aug 26, 10:00 pm, Neha Gupta nehagup...@gmail.com wrote: college? -- 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: unsorted array problem

2011-08-26 Thread Dave
@Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers getting 7 = 111 in binary. Now how do we divide the numbers into two groups? Dave On Aug 26, 11:09 am, tech coder

[algogeeks] Re: Playdom Interview ques

2011-08-26 Thread Navneet
The function of that flag would be to decide direction (bottom up or top down/ left to right or otherwise) On Aug 26, 6:15 pm, Navneet navneetn...@gmail.com wrote: Also for ques 1, instead of having four auxiliary functions, you can have a variable flag for rows and cols functions being passed

[algogeeks] Re: C Trick

2011-08-26 Thread Dave
@Rajesh: abs() can be done without conditional operations. There probably are many ways. The first two that come to mind are: abs(x) = (x 31) x | ~(x 31) ~x abs(x) = (x 31) ^ x + (x 31) 1 Dave On Aug 26, 2:56 am, rajesh singarapu rajesh0...@gmail.com wrote: abs function itself has a

Re: [algogeeks] Samsung India Electronics Limited vs Winshuttle

2011-08-26 Thread Algo'nAlgo
And in my college , samsung is giving 6.25lpa whereas winshuttle 7lpa with dream status.. thats y a bit confused :O -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Find all the subsets whose sum = k

2011-08-26 Thread Piyush Grover
Here is a problem: Given an array of size n. Find all the MAXIMAL subsets whose sum is = K. The solution is not a concern, the optimization is required. -piyush -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: unsorted array problem

2011-08-26 Thread Don
I believe this is what techcoder is saying: int a[N]; // Find the bitwise xor of all the array values. // These are the bits which are different between the two results. int xor = 0; for(i = 0; i N; ++i) xor ^= a[N]; // Find the low order bit of xor int bit = 1; while(!(xor bit)) bit = 1;

[algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread rahul sharma
take h as array/has table as max element of a as size. just a psecudeocde. for(i=0;in;i++) { sub=k-a[i]; if(h[a[i]]==1) return (a[i],sub); h[a[i]]=1; } log n complexity for all subsets of sum=k;;; just add one more condition in loop for checkeing also... coreect if m wrng?? On Aug

[algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread rahul sharma
yeah can be done in poly tym also...but we dnt knw whether we have unsorted arryit is possible in sorted array. On Aug 26, 10:52 pm, Don dondod...@gmail.com wrote: This is the knapsack problem. Find a polynomial-time solution and you will be a hero. Don On Aug 26, 12:43 pm, Piyush Grover

Re: [algogeeks] Re: unsorted array problem

2011-08-26 Thread Sanjay Rajpal
XOR all the elements in the array, the result will be the XOR of the two numbers occuring odd number of times. Now take any set bit of th result(u can determine the position of any bit set in the number). Divide the array such that for the numbers for which at this location(where the bit is set

Re: [algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread Piyush Grover
@rahul...I'm unsure if your algo returns all the subsets. On Fri, Aug 26, 2011 at 11:24 PM, rahul sharma rahul23111...@gmail.comwrote: yeah can be done in poly tym also...but we dnt knw whether we have unsorted arryit is possible in sorted array. On Aug 26, 10:52 pm, Don

[algogeeks] Re: unsorted array problem

2011-08-26 Thread Dave
@Tech, Don: How about this: given n and array a[n]: int x = 0, result[2] = {0}; for( i = 0 ; i n ; ++i ) x ^= a[i]; x |= x(x-1); // low order 1-bit of xor for( i = 0 ; i n ; ++i ) result[a[i]x?0:1] ^= a[i]; Dave On Aug 26, 12:49 pm, Don dondod...@gmail.com wrote: I believe this is

[algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread rahul sharma
yes it will return in c return 1 value at tym... ijust given the code snipetjust modify it..store trhm in some other array like thebut it will On Aug 26, 11:02 pm, Piyush Grover piyush4u.iit...@gmail.com wrote: @rahul...I'm unsure if your algo returns all the subsets. On Fri,

[algogeeks] apti!

2011-08-26 Thread priya ramesh
A certain number of men can finish a piece of work in 10 days. If however there were 10 men less it will take 10 days more for the work to be finished. How many men were there originally? (a) 110 men (b) 130 men (c) 100 men (d) none of these -- You received this message because you are

Re: [algogeeks] apti!

2011-08-26 Thread gmagog...@gmail.com
20? Yanan Cao On Fri, Aug 26, 2011 at 1:12 PM, priya ramesh love.for.programm...@gmail.com wrote: A certain number of men can finish a piece of work in 10 days. If however there were 10 men less it will take 10 days more for the work to be finished. How many men were there originally?

[algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread Don
@rahul Your code will only find pairs which sum to k. The problem is to find a subset of as many elements in the array as required to sum as close as possible to k. It is a well-known problem and after years of study, no polynomial solution is known. There are reasonably fast solutions for small

Re: [algogeeks] apti!

2011-08-26 Thread priya ramesh
i too got the same ans. -- 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,

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
20 men ? (x-10)20=10x Sanju :) On Fri, Aug 26, 2011 at 11:17 AM, gmagog...@gmail.com gmagog...@gmail.comwrote: 20? Yanan Cao On Fri, Aug 26, 2011 at 1:12 PM, priya ramesh love.for.programm...@gmail.com wrote: A certain number of men can finish a piece of work in 10 days. If however

Re: [algogeeks] apti!

2011-08-26 Thread Rahul Verma
@yanan how it is 20. Rahul Verma -- 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/-/uIONcvrf6kUJ. To post to this group, send email to

Re: [algogeeks] apti!

2011-08-26 Thread priya ramesh
the answer is 130 itseems. i too got 20 -- 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

Re: [algogeeks] apti!

2011-08-26 Thread gmagog...@gmail.com
@Rahul Assume the productivity of each man is the same let original number of man be x The total workload= x*10*p also workload = (x-10)(10+10)*p solve it so x=20 Yanan Cao On Fri, Aug 26, 2011 at 1:21 PM, Rahul Verma rahul08k...@gmail.com wrote: @yanan how it is 20. Rahul Verma --

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
Sry for prrevious post . It is question of R S Aggarwal, and solved using conecpt of direct and indirect proportions. Originally,let there be x men. Less men,more days(indirect proposition) (x-10) : x :: 100 : 110 (x-10) * 110 = x * 100 ANS : x = 110 Sanju :) On Fri, Aug 26, 2011 at

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
In this question, instead of 10, it is 100. Check it again. Sanju :) On Fri, Aug 26, 2011 at 11:26 AM, Sanjay Rajpal srn...@gmail.com wrote: Sry for prrevious post . It is question of R S Aggarwal, and solved using conecpt of direct and indirect proportions. Originally,let there be x

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
If it is 10 days originally, answer is 20 for sure. Sanju :) On Fri, Aug 26, 2011 at 11:27 AM, Sanjay Rajpal srn...@gmail.com wrote: In this question, instead of 10, it is 100. Check it again. Sanju :) On Fri, Aug 26, 2011 at 11:26 AM, Sanjay Rajpal srn...@gmail.com wrote: Sry

Re: [algogeeks] apti!

2011-08-26 Thread Piyush Grover
it's basic unitary method problem: x men do work in 10 days 1 man will do-in 10*x days x-10 men do it in 10*x/(x-10) = (10+10) Solve it and x = 20 it can't be 130 On Fri, Aug 26, 2011 at 11:53 PM, gmagog...@gmail.com gmagog...@gmail.comwrote: @Rahul Assume the productivity of each man

Re: [algogeeks] apti!

2011-08-26 Thread priya ramesh
oh thanks :) It's given as 10 only. Printing mistake i guess. -- 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

Re: [algogeeks] Re: unsorted array problem

2011-08-26 Thread tech coder
@Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers getting 7 = 111 in binary. Now how do we divide the numbers into two groups? see we come to know that both number differ at

Re: [algogeeks] Re: unsorted array problem

2011-08-26 Thread tech coder
@ Don exactly waht u write i wanted to say On Fri, Aug 26, 2011 at 11:52 AM, tech coder techcoderonw...@gmail.comwrote: @Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers

[algogeeks] SPOJ ACODE

2011-08-26 Thread kartik sachan
i am getting repeatdly WA in this question link is https://www.spoj.pl/problems/ACODE/ plzz provide me some test cases where my code fails. my code is # includecstdio # includecstring int main() { while(1) { char a[50100]; scanf(%s,a);

[algogeeks] Re: puzzle

2011-08-26 Thread icy`
I hope you dont mind that I respond to the original question about the 6x6 matrix. As I understand it, all elements have to be either 1 or -1, and product of *every* row and *every* column is 1 = how many arrangements? Now a bunch of you seem to think(nxn) = 2^((n-1)^2) gives the answer,

[algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread Don
The 0-1 knapsack problem is still the knapsack problem. Don On Aug 26, 1:55 pm, Piyush Grover piyush4u.iit...@gmail.com wrote: it's similar to knapsack but not the same. In knapsack, types of items are limited and we play on the quantity of each item. Here each element will come once in the

Re: [algogeeks] unsorted array problem

2011-08-26 Thread Rahul Verma
@Umesh I really appreciate your solution and thinking to understand the complexity of the program. Actually I don't have that much idea about the *how to calculate complexity of any program*. So could you please show some light on the evaluation procedure of complexity. Rahul Verma -- You

Re: [algogeeks] Re: puzzle

2011-08-26 Thread Piyush Grover
Cut the rope in 50mtrs and 100mtrs length. Make a small loop(of negligible length at one end of the 50 mtrs rope) Tie the other end of the rope at the top and from the loop end side pass the 100mtrs rope such that you have both the ends of 100mtrs rope in your end. now get down at 100mtrs peg

[algogeeks] Recruitment Procedure for Microsoft Research Redmond and Bangalore

2011-08-26 Thread shady
Does anyone know about the recruitment procedure for Research Intern at MS Redmond or MS Bangalore ? What are the type of questions do they ask and what should be paid attention to ? There are lot of posts on MS SDE and SDET positions but none about research. If anyone knows then kindly reply.

[algogeeks] Re: puzzle

2011-08-26 Thread icy`
Other than making little loops and risking the fall on the first trip down, I dont think the rope question has an answer. NVIDIA just wanted to see if you were suicidal =D On Aug 26, 3:36 pm, Piyush Grover piyush4u.iit...@gmail.com wrote: Cut the rope in 50mtrs and 100mtrs length. Make a

Re: [algogeeks] Re: puzzle

2011-08-26 Thread SuDhir mIsHra
i hope now it clear: [image: Screenshot.png] -- 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

Re: [algogeeks] Re: Suggestion

2011-08-26 Thread Rahul
If the seeker wants to do entire self study , then I would suggest CS 106B Reader , it's in C ++ , BUT ideal for people who rely only on internet. ALso that Data STructure USing C ,Book by Y. KAnitikar , I never saw any math in any chapters for analysis of algorithms they write . lol. Google it

Re: [algogeeks] Re: puzzle

2011-08-26 Thread Anup Ghatage
Check this out: Tie it at the 200th meter mark. Throw the 150mt rope down. Climb down to the 100th meter pole. Tie the rope there from the middle, and not the end. So what you have is a 150 mt rope that is tied at 200 mt mark, 100 mt mark and 50 mts of the rope from 100 mt marks is hanging.

Re: [algogeeks] Re: Find all the subsets whose sum = k

2011-08-26 Thread raj kumar
It's not knapsack in knapsack we find max or min subset here we have to find all subsets =k not just one which is min or max , so I guess we have to form all subsets and check their sum hence the algoritm will be 0(2^n) where n is number of elements in the set , please correct me if i am wrong or

Re: [algogeeks] Re: unsorted array problem

2011-08-26 Thread raj kumar
@don really cool algo man -- 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,

Re: [algogeeks] Re: Suggestion

2011-08-26 Thread ankit arun
thanks everybody for so many suggestions... :) On Sat, Aug 27, 2011 at 6:40 AM, Rahul raikra...@gmail.com wrote: If the seeker wants to do entire self study , then I would suggest CS 106B Reader , it's in C ++ , BUT ideal for people who rely only on internet. ALso that Data STructure USing C

  1   2   >