Re: [algogeeks] Re: Exchanging bit values in a number

2011-11-14 Thread sanjiv yadav
suppose we have to swap bits b1 and b2 in a number n.Then if(b1==b2) do not do any thing else take a hexadecimal number whose all bits are zero except bits b1 and b2.bit b1=1 and bit b2=1 now xor of original no with this no will give the desired result. On Sun, Oct 30, 2011 at 10:32 AM,

[algogeeks] Re: heap memory

2011-11-14 Thread sumit mahamuni
On Nov 5, 10:28 pm, himanshu kansal himanshukansal...@gmail.com wrote: can we know the size of heap memory allocated to our program Hi, from my knowledge of OS, when program is loaded in the memory the heap is not allocated to the process. as the requests made by the process, the

[algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread Aniket
You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is

[algogeeks] Algm

2011-11-14 Thread Vijay Khandar
Which is the sorting algm sorts the integers [1...n^3] in O(n). a)Heapsort b)Quicksort c)Mergesort d)Radix sort please tell anyone. Vijay. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread Ankur Garg
We can use a trie here .. Create a trie with all words of dictionary . Now delete the last character of the word and check if such a word is a valid word . If not see if adding a new character can make it a valid word . If not delete the next character and repeat the process again . This is what

Re: [algogeeks] Algm

2011-11-14 Thread Piyush
Has to be (d) Radix sort (using counting sort, which will sort the individual digits in O(n) time). -- 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] Algm

2011-11-14 Thread Carl Barton
Bit confused by your n^3. Could you clarify? In the mean time Radix is an O(n) sorting algorithm. Where n is the length of the array. On 14/11/2011, Vijay Khandar vijaykhand...@gmail.com wrote: Which is the sorting algm sorts the integers [1...n^3] in O(n). a)Heapsort b)Quicksort

Re: [algogeeks] Re: Exchanging bit values in a number

2011-11-14 Thread sanjiv yadav
suppose we have to swap bits b1 and b2 in a number n.Then if(b1==b2) do nothing else take a hexadecimal number whose all bits are zero except bits b1 and b2.bit b1=1 and bit b2=1 now xor of original no with this no will give the desired result. On Sun, Oct 30, 2011 at 10:32 AM, shiva@Algo

Re: [algogeeks] what will be the focus of yahoo in written exam ,what to study for it. please respond ASAP..

2011-11-14 Thread wujin chen
two month ago , I passed yahoo written test in china. data structure, algorithm , and given a code segment with some lines missing, ask you to fill it. today i rejected yahoo offically. actually i love to be one of yahoo. finally i chose microstrategy in hangzhou ,china, because it is close

Re: [algogeeks] Algm

2011-11-14 Thread hary rathor
d cause of a b c have complexity o(nlogn) -- 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.

Re: [algogeeks] Re: Exchanging bit values in a number

2011-11-14 Thread sanjiv yadav
suppose we have to swap bits b1 and b2 in a number n.Then if(b1==b2) do nothing else take a hexadecimal number whose all bits are zero except bits b1 and b2.bit b1=1 and bit b2=1 now xor of original no with this no will give the desired result.suppose we have to swap bits b1 and b2 in a

[algogeeks] Re: Algm

2011-11-14 Thread Anurag Gupta
that means the range of input is 1 to n^3 i.e there are n numbers and the numbers can vary from 1 to n^3 On Nov 14, 3:48 pm, Carl Barton odysseus.ulys...@gmail.com wrote: Bit confused by your n^3. Could you clarify? In the mean time Radix is an O(n) sorting algorithm. Where n is the length

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread aniket chatterjee
yeah, that is normal bryteforce. Any better idea? On 11/14/11, Ankur Garg ankurga...@gmail.com wrote: We can use a trie here .. Create a trie with all words of dictionary . Now delete the last character of the word and check if such a word is a valid word . If not see if adding a new

Re: [algogeeks] Amazon Question

2011-11-14 Thread Nitin Garg
@surendra - converse is not true. aabbcc will be reduced 2. aabbcc can be reduced to acbcc acbcc has unequal number of a's,b's and c's. Hence it should be reducable to 1. On Sun, Nov 13, 2011 at 3:42 PM, Anika Jain anika.jai...@gmail.com wrote: its coming out be either 1 or 2 in all cases

Re: [algogeeks] Re: How to find highest power of 2 in an integer

2011-11-14 Thread saurabh singh
The very obvious sudo code would be: count=0 while n is not 0 do right shift bits of n count=count+1 done return count Though i still get a feel a better logic must be there,... On Mon, Nov 14, 2011 at 4:26 PM, Gene gene.ress...@gmail.com wrote: Actually aren't you off by 1 in each case?

[algogeeks] spoj problem

2011-11-14 Thread Anshul AGARWAL
problem is http://www.spoj.pl/problems/ELEVTRBL/ and my solution is give wrong answer on spoj . Plz help me to find in which case my solution give wrong answer. * #includeiostream ** #includestdio.h using namespace std; int main() { long long int f,s,u,d,g,c,p;

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread rajeev bharshetty
Levensteins algorithm On 14 Nov 2011 18:19, aniket chatterjee aniket...@gmail.com wrote: yeah, that is normal bryteforce. Any better idea? On 11/14/11, Ankur Garg ankurga...@gmail.com wrote: We can use a trie here .. Create a trie with all words of dictionary . Now delete the last

Re: [algogeeks] spoj problem

2011-11-14 Thread shady
what;s your algorithm ? On Mon, Nov 14, 2011 at 7:57 PM, Anshul AGARWAL anshul.agarwa...@gmail.comwrote: problem is http://www.spoj.pl/problems/ELEVTRBL/ and my solution is give wrong answer on spoj . Plz help me to find in which case my solution give wrong answer. * #includeiostream **

[algogeeks] Re: How to find highest power of 2 in an integer

2011-11-14 Thread Dave
@Ankur: Try this: int HighestBitSet (unsigned int n) { int exp; double x = frexp((double)n, exp); return exp-1; } To see how it works, look up the standard C++ function frexp. Dave On Nov 14, 12:06 am, Ankur Goel goel.anku...@gmail.com wrote:  How to find highest power of 2 in an

[algogeeks] Re: How to find highest power of 2 in an integer

2011-11-14 Thread Don
Can you define the question more precisely? Do you want the largest power of 2 = n, or the largest power of two which divides into n? In the first case, it is the number of digits after the leftmost 1 in the binary representation. In the latter case, it is the number of trailing zeros in the

Re: [algogeeks] spoj problem

2011-11-14 Thread Anshul AGARWAL
i m try to increase current floor c by push up button until it equal or greater than g and increase co-responding push p.when my current floor is greater than g.i push down button once and increase p by 1. repeat this loop until i get c==g. *Anshul Agarwal Nit Allahabad Computer Science** *

Re: [algogeeks] what will be the focus of yahoo in written exam ,what to study for it. please respond ASAP..

2011-11-14 Thread aditya kumar
guys this is not the ideal place to discuss placement related questions . plz query in interviewstreet group On Mon, Nov 14, 2011 at 5:24 PM, wujin chen wujinchen...@gmail.com wrote: two month ago , I passed yahoo written test in china. data structure, algorithm , and given a code segment

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

2011-11-14 Thread AMAN AGARWAL
Hi, I think it matters whether its a bst or normal tree. In BST left node is smaller and the right node is greater than the root node, but no such constraint is applicable for a binary tree. Regards, Aman. On Mon, Nov 14, 2011 at 10:12 AM, sumit mahamuni sumit143smail...@gmail.com wrote: Hi,

Re: [algogeeks] Re: How to find highest power of 2 in an integer

2011-11-14 Thread UTKARSH SRIVASTAV
we can get it by ceil(log2n) On Mon, Nov 14, 2011 at 8:38 PM, Don dondod...@gmail.com wrote: Can you define the question more precisely? Do you want the largest power of 2 = n, or the largest power of two which divides into n? In the first case, it is the number of digits after the leftmost

Re: [algogeeks] spoj problem

2011-11-14 Thread sunny agrawal
one solution is use BFS On Mon, Nov 14, 2011 at 8:52 PM, Anshul AGARWAL anshul.agarwa...@gmail.com wrote: i m try to increase current floor c by push up button until it equal or greater than  g  and increase co-responding push p.when my current floor is greater than g.i push down button once

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread aniket chatterjee
@Rajeev: The above algorithm assumes a source string and a destination string. But here you are provided only the source string. And you will have to edit it (minimally) such that the resulting string matches a word in the dictionary. Need slight modification. Looking for the modification.

[algogeeks] Re: spoj problem

2011-11-14 Thread Don
I solved this one with a breadth-first search. Don On Nov 14, 8:27 am, Anshul AGARWAL anshul.agarwa...@gmail.com wrote: problem ishttp://www.spoj.pl/problems/ELEVTRBL/ and my solution is give wrong answer on spoj . Plz help me to find in which case my solution give wrong answer. *

[algogeeks] NULL pointer

2011-11-14 Thread UTKARSH SRIVASTAV
is subtraction of two NULL pointers defined ? -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd 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 to algogeeks@googlegroups.com. To unsubscribe from

[algogeeks] Network flow question

2011-11-14 Thread Sundi
Let G(V, E) be a weighted undirected graph. Let the value of a spanning tree be the minimum weight of the edges. Let the cap from a cut [S, V - S] (i.e, the set of undirected edges that connect a node in S to a node in the remaining set V -S) be the maximum weight of its edges. Prove that the

Re: [algogeeks] NULL pointer

2011-11-14 Thread kartik sachan
yup. -- 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] LCA of a Binary tree not a binary search tree

2011-11-14 Thread sumit mahamuni
Yeah, right. the same algo of binary tree can be used for bst also but using that is expensive. On Mon, Nov 14, 2011 at 9:56 PM, AMAN AGARWAL mnnit.a...@gmail.com wrote: Hi, I think it matters whether its a bst or normal tree. In BST left node is smaller and the right node is greater than

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread Anup Ghatage
Aren't there multiple words that can be returned from the dictionary after various operations? eg: input string: CODE If we go on walking the trie for the dictionary, we'll get results C, CO, COD, CODA, CODE. So multiple edit distance operations can be done to each of the instances shown above