Re: [algogeeks] Re: amazon,microsoft link list probs

2011-10-10 Thread rahul patil
On Thu, Oct 6, 2011 at 3:30 PM, 9ight coder 9ightco...@gmail.com wrote: hey ankit can u show me 1st question solution On Oct 5, 9:06 pm, Ankur Garg ankurga...@gmail.com wrote: Implement recursive merge sort for first question(Implement recursive merge sort for first question ) For

Re: [algogeeks] Re: Algo for Search in a 2D Matrix

2011-10-10 Thread shiva@Algo
id we see the pattern then we can easily find that the kth smallest element lie on the upper half of the k*k submatrix(on the upperleft corner ) we can do search on (k*k)/2 elements to find that On Mon, Oct 10, 2011 at 10:36 AM, Dave dave_and_da...@juno.com wrote: @Shubham: So if the matrix is

[algogeeks] How to Solve This

2011-10-10 Thread VIHARRI
For every number that has 3 in its units place has one multiple which has all one's i.e. 111 is such multiple and 13 has a multiple 11. Write a program to find such multiple for any number that has 3 at its units place. -- You received this message because you are subscribed to the Google

[algogeeks] Posts on INTERVIEW QUERIES will be REMOVED

2011-10-10 Thread siva viknesh
If you want ask for any interview or company related queries , kindly join new group. http://groups.google.com/group/interview-street ..Only ALGORITHM RELATED interview questions from any company will be posted ...Kindly notify your friends too For more details visit this thread...

[algogeeks] Additive sequence

2011-10-10 Thread anand karthik
Hi, I dont remember the question text exactly but the following should convey it well The question: A number is said to be an additive number if it has the following format: 3268126844 : 32 6812 6844 : 32 + 6812 = 6844 123581321 : 1 2 3 5 8 13 21 : 1+2 = 3 , 2+3 = 5 , 3+5=8, 5+8 = 13, 8+13

Re: [algogeeks] How to Solve This

2011-10-10 Thread anshu mishra
string all1Multiple(int x) { string s; setint mySet; mySet.push(0); int psize, r=1; do { psize = mySet.size(); s += '1'; r = r % x; mySet.push(r); r = r * 10 + 1; } while(mySet.size() psize); if (r != 1) return not Possible; return s; } -- You received this message because you are subscribed

Re: [algogeeks] Fwd: why we can not swap values using macro?

2011-10-10 Thread rahul sharma
macros i thnik cant swap pointers..i have doubt for same it is test ur c skil question On Sun, Oct 9, 2011 at 10:08 PM, sunny agrawal sunny816.i...@gmail.comwrote: because you have not made any call to swap values of x and y I Don't know what you are trying to do here if you want to swap

[algogeeks] Memorization

2011-10-10 Thread arvind kumar
Can anyone tell me how to go about with the memorization technique to retrieve values from already stored values,in case of eveluating sequences(fibonacci series,etc).? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Fwd: why we can not swap values using macro?

2011-10-10 Thread sunny agrawal
Macros can Swap Pointers. and That is what the above code is doing. On Mon, Oct 10, 2011 at 5:52 PM, rahul sharma rahul23111...@gmail.comwrote: macros i thnik cant swap pointers..i have doubt for same it is test ur c skil question On Sun, Oct 9, 2011 at 10:08 PM, sunny agrawal

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sandeep nagamalli
@Shiva: How can min heap be uesd, can you eloborate a bit. As far as i see, the best possible is O(nlogn) i.e by sorting and scanning over the complete array once. On Mon, Oct 10, 2011 at 9:49 AM, shiva@Algo shiv.jays...@gmail.com wrote: I think Min heap will do that.. On Mon, Oct 10,

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread Deoki Nandan
just find minimum and secon minimum by taking two variables in O(n) On 10 October 2011 17:57, sandeep nagamalli nsandee...@gmail.com wrote: @Shiva: How can min heap be uesd, can you eloborate a bit. As far as i see, the best possible is O(nlogn) i.e by sorting and scanning over the complete

[algogeeks] subset of an array

2011-10-10 Thread Rashmi Jain
algo to find subsets of an array whose sum is equal to a given number..? -- 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: Give Algo to do this in O(n)

2011-10-10 Thread sravanreddy001
Without sorting the elements we have around n^2 elements to look from, to find the smalled element. But, after sort, we will have only n-1 elements to look from. So, O(nlogn) is what I see, the best case. Is there really a O(n) solution, as finding the diff between elements should be done

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread snehi jain
@ ankur: if space is not the consideration first sort them using count sort and then look for the pair with the min. difference .. i think it should work . Snehi On Mon, Oct 10, 2011 at 7:21 PM, anubhav gupta anubhav.7...@gmail.comwrote: @deoki try for 1001,999,998,1 On Mon, Oct 10,

Re: [algogeeks] subset of an array

2011-10-10 Thread Hatta
is it a contiguous set, any sparse subset or what? if it's a subset of a set then it can be sparse, but when you say array you make it quite tricky to figure out. with all due respect sir, please mind that when you make a question you're taking peoples time to answer it therefore if the answer

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sravanreddy001
Just went throught what a count sort is at http://en.wikipedia.org/wiki/Counting_sort If all the elements are distinct which is possible, will this count sort have any use? Also, the sorting takes O(nlogn) time right? Did I miss anything? -- You received this message because you are

[algogeeks] Re: why we can not swap values using macro?

2011-10-10 Thread sravanreddy001
The swap is happenning between the p q pointers, https://ideone.com/4MdX4 p points to y, q points to x after swap. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] subset of an array

2011-10-10 Thread Rashmi Jain
not necessary contiguous.. eg: we are given with an array-1,4,2,26,8,3 and we need to find the subsets of this having sum of its members as 11. ans should be 1,2,8 and 8,3 i hope i am clear this time.. On Mon, Oct 10, 2011 at 9:38 PM, Hatta tmd...@gmail.com wrote: is it a contiguous set, any

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread Ankur Garg
@Sravan ..Counting Sort takes O(n) time but it needs range of nos to be known @Snehi jain..there is no range given so am not sure if count sort will work ,Can you please elaborate a bit on ur method Ankur On Mon, Oct 10, 2011 at 10:09 PM, sravanreddy001 sravanreddy...@gmail.comwrote: Just went

Re: [algogeeks] Memorization

2011-10-10 Thread Ankur Garg
Memoization ? On Mon, Oct 10, 2011 at 6:34 PM, arvind kumar arvindk...@gmail.com wrote: Can anyone tell me how to go about with the memorization technique to retrieve values from already stored values,in case of eveluating sequences(fibonacci series,etc).? -- You received this message

[algogeeks] remove duplicate words from a string

2011-10-10 Thread sachin goyal
remove duplicate words from a string with min. complexityy. -- 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] subset of an array

2011-10-10 Thread anshu mishra
the simplest code could be for this question is void printAllSubsetSum(int ar[], int n, int x) { for (i = 0; i (1n); i++) { int sum = 0; for (j = 0; j n; j++) { if ( (1 j) i) sum += ar[j]; } if (sum == x) {

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread snehi jain
ankur : i wont say its the best way, but it can be used in one traversal the range can be determined and then count sort can be applied. On Mon, Oct 10, 2011 at 10:56 PM, Ankur Garg ankurga...@gmail.com wrote: @Sravan ..Counting Sort takes O(n) time but it needs range of nos to be

Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sunny agrawal
Counting Sort is really a Bad option for this Problem as range is not given yes range can be find in single traversal but think if largest element is 10^9 and size of the array is just about 10^3 Counting Sort = O(10^9) Simple Sorting = O(10^4) Counting sort will perform bad in this case both in

Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread Ankur Garg
I think this can be done through tries Any better solution ? On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal monugoya...@gmail.comwrote: remove duplicate words from a string with min. complexityy. -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread sunny agrawal
Trie will take too much space.. Balanced Binary tree can be Better ...?? On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg ankurga...@gmail.com wrote: I think this can be done through tries Any better solution ? On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal monugoya...@gmail.comwrote: remove

[algogeeks] Re: Give Algo to do this in O(n)

2011-10-10 Thread Dave
A radix sort would provide an O(n) solution for any fixed-size integer data type. Dave On Oct 10, 10:19 am, sravanreddy001 sravanreddy...@gmail.com wrote: Without sorting the elements we have around n^2 elements to look from, to find the smalled element. But, after sort, we will have only

[algogeeks] i cannot solve this written test question

2011-10-10 Thread icy`
one possible ruby solution/pic attached -- 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.

[algogeeks] i cannot solve this written test question

2011-10-10 Thread icy`
one possible solution in ruby (sry if this is double-posted -- i did not see it come up the first time) [image: digsum_output.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] Re: remove duplicate words from a string

2011-10-10 Thread icy`
a) 1. could split the string using a regexp (into an array) in which you define a word -- is hi. the same as hi, and hi ? 2. then perform a unique operation on the array (some languages have this built in) to remove duplicates 3. recombine array elements into string by joining with a space,

[algogeeks] Find the later version

2011-10-10 Thread bagaria.ka...@gmail.com
Given two strings describing the version of a particular software need to find the later version. For eg. 1st string = 1.2.4.5 2nd string=1.2.3.5 1st string is the later one. Can be done using traversing the string and comparing each character one after the another. Looking for a better

Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread Ankur Garg
@Sunny..How do u intend to store them in a Tree ? Can you explain ? In a trie u first insert the first word ..take the second word..If its not present in the trie u insert it else remove it from original string .Alternatively u store the elements in a trie in the initial string and terminate it

Re: [algogeeks] Find the later version

2011-10-10 Thread sheetal naidu
divide the string in middle and first compare the left sub-string(as they are MSB)...if they match then compare the right sub-string (iteratively) if the left substring doesn't match then compare iteratively by dividing again. i think this would give complexity in lgn. Hope this helps!! On 11

Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread sunny agrawal
@Ankur in Trie at each Node there will be 26 Pointers Stored, and Most of them would be NULL, thats why i think it will waste space, in Balanced Binary Tree i was thinking of storing the Complete Words at a Node. But now i think this is Better - Ternary Search

[algogeeks] Re: Find the later version

2011-10-10 Thread Dave
@Karen: It is more complicated than scanning character by character. E.g., 1.10.3 is older than 1.9.7. I think you need to parse the numbers between the dots and compare them one by one. Thus, in the above example, 1 compares equal to 1, so you keep scanning. Then 10 compares greater than 9 so the

Re: [algogeeks] subset of an array

2011-10-10 Thread abhishek sharma
yea DP will be O(given no * n) if all array entries are positive and the given no is non negative. On Mon, Oct 10, 2011 at 11:09 PM, anshu mishra anshumishra6...@gmail.comwrote: the simplest code could be for this question is void printAllSubsetSum(int ar[], int n, int x) { for (i = 0;

[algogeeks] Given a String with unnecessary spaces, compact it in place

2011-10-10 Thread abhishek sharma
Can in place compaction be done without left shifts? -- Nice Day Abhishek Sharma Bachelor of Technology IIT Kanpur (2009) -- 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