[algogeeks] Question on algo

2015-10-05 Thread *$*
Little Black Panda is mad about XOR operation. Presently he has gone mad and he won't stop performing XOR operation on various numbers. Given an array of N numbers, for each subset of the array Little Panda performs MAXOR operation for the subset. MAXOR operation means that he finds XOR of all

Re: [algogeeks] Question

2013-03-12 Thread Sairam
No, it is only O(n), but space will be order of O(maximum element in the range) Because only one loop to go through all the intervals and get the maximum. Then allocate space for that much, after that again go through intervals and increment the corresponding value. Then after that finding

Re: [algogeeks] Question

2013-03-01 Thread Abioy Sun
segment tree 2013/2/18 bharat b bagana.bharatku...@gmail.com: @ richard : u'r algo takes O(n^2) time .. try to write code ... u'll come to know.. On Sun, Feb 17, 2013 at 1:13 PM, Richard Reed exp.r...@gmail.com wrote: If the times are discrete, you can create an array with the size of

Re: [algogeeks] Question

2013-02-18 Thread bharat b
@ richard : u'r algo takes O(n^2) time .. try to write code ... u'll come to know.. On Sun, Feb 17, 2013 at 1:13 PM, Richard Reed exp.r...@gmail.com wrote: If the times are discrete, you can create an array with the size of discrete time (0 to whatever, adjusted). For each time slot, add 1 to

Re: [algogeeks] Question

2013-02-17 Thread atul anand
related to this problem, link given below :- http://groups.google.com/group/algogeeks/browse_thread/thread/7cfb0a6f7d121d92/0adc692fad1bab40?hl=enlnk=gstq=DP+equation+for+interval+problem#0adc692fad1bab40 -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Question

2013-02-17 Thread Richard Reed
If the times are discrete, you can create an array with the size of discrete time (0 to whatever, adjusted). For each time slot, add 1 to each index of the array that corresponds to a time range. Then iterate through the list to find the highest time tally. This is an O(n) solution. On Sat, Feb

[algogeeks] Question

2013-02-16 Thread shady
Given a number of time slots – start time and end time,“a b”, find any specific time with the maximum number of overlapping. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send

[algogeeks] Question on checking divisibility of binomial coefficients of a number by a prime number

2012-08-26 Thread Ankit Singh
In mathematics, *binomial coefficients* are a family of positive integers that occur as coefficients in the binomial theorem. [image: \tbinom nk]denotes the number of ways of choosing k objects from n different objects. However when n and k are too large, we often save them after modulo

Re: [algogeeks] question

2012-08-22 Thread Arman Kamal
Convert the integer to a binary string. From the right (that is least significant bit), find the first occurence of 01 in the string. For example.. if the string is *00110 **01 **11100*, notice the isolated part, that is what you have to find. Then simply flip the 01 to 10.. like *00110*

[algogeeks] question

2012-08-21 Thread megha agrawal
Can anyone suggest solution for this problem? You are given an unsigned integer.Write a function to print the next number which will be having same number of 1 bits present in given num. eg) 6(110) to 9(1001) -- You received this message because you are subscribed to the Google

Re: [algogeeks] question

2012-08-21 Thread Arun Kindra
a) count total no of bit set in given no b) increment the given no by one and count the no of bit set in it if it equal to the above count then return else increment the no till u get the count equals the above one. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-30 Thread himanshu kansal
i think this algo will do... reverse the given prefix expression while(!nd of input) { if it is operand push in a stack if its an operator { op1=pop(stack); op2=pop(stack); push (op1 op2 operator) on to stack; } } On Sat, Jun 30,

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-30 Thread utsav sharma
@bhaskar himanshu :- can u please explain ur algo for a * ( b + ( ( c - d ) / e ) ) On Sat, Jun 30, 2012 at 11:50 AM, himanshu kansal himanshukansal...@gmail.com wrote: i think this algo will do... reverse the given prefix expression while(!nd of input) { if it is operand

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-30 Thread achala sharma
I think no need to reverse the string,following program is giving me correct o/p.Although right now this program will work only for binary operator,for unary add extra condition main() { char str[100]; int i=0; int digit; scanf(%s,str); while(str[i]) { if(isdigit(str[i])) {

[algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread Gobind Kumar Hembram
Given an integer expression in a prefix format (i.e. the operator precedes the number it is operating on) , print the expression in the post fix format . Example: If the integer expression is in the prefix format is *+56-78, the postfix format expression is 56+78-*. Both of these correspond to

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread Bhaskar Kushwaha
I think just reversing the prefix notation converts it to postfix notation On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram gobind@gmail.comwrote: Given an integer expression in a prefix format (i.e. the operator precedes the number it is operating on) , print the expression in the

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread amrit harry
@bhaskar ur algo fails on this case (5+3)-(2+(3/6)) -+53+2/36 63/2+35-+ showing that 6/3 but actually it is 3/6 so i think it could be done by folowing algo make a binary tree of given expression in O(n) then do postorder traversal take O(n) so problem can be solved in O(n). and take O(2*n+1)

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread rahul ranjan
oh bhai mere. kewal preorder use karke kaise tree bana dega??? On Fri, Jun 29, 2012 at 11:23 PM, amrit harry dabbcomput...@gmail.comwrote: @bhaskar ur algo fails on this case (5+3)-(2+(3/6)) -+53+2/36 63/2+35-+ showing that 6/3 but actually it is 3/6 so i think it could be done by

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread Abhishek Sharma
convert prefix to infix,then convert infix to postfix.Now, to convert prefix to infix, push numbers in one stack and operators in other.Then use thishttp://www.velocityreviews.com/forums/t445633-prefix-to-infix-conversion.html algo to perform this.Then do the same for infix to postfix.It works

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread Bhaskar Kushwaha
reverse the prefix notation and then reverse each continuous occurence of operands On Sat, Jun 30, 2012 at 12:50 AM, Abhishek Sharma abhi120...@gmail.comwrote: convert prefix to infix,then convert infix to postfix.Now, to convert prefix to infix, push numbers in one stack and operators in

Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread Bhaskar Kushwaha
example -+53+2/36 step 1: 63/2+35+- step 2: 36/2+53+- On Sat, Jun 30, 2012 at 1:55 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: reverse the prefix notation and then reverse each continuous occurence of operands On Sat, Jun 30, 2012 at 12:50 AM, Abhishek Sharma

[algogeeks] Question asked in Tachyon interview

2012-06-27 Thread Gobind Kumar Hembram
Write C code to implement level order traversal of a tree. -- 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] Question asked in Tachyon interview

2012-06-27 Thread hary rathor
apply BFS -- 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

Re: [algogeeks] Question asked in Tachyon interview

2012-06-27 Thread megha agrawal
int mul(int a, int b) { int r=0; if (a==0|| b==0) r=0; else { for(int i=0;ib;i++) r=r+a; } return r; } On Wed, Jun 27, 2012 at 10:46 AM, Prateek Jain prateek10011...@gmail.comwrote: main(a,b,m) 02{ 03while (~scanf(%d%d,a,b)) 04{ 05 m=0; 06 while (a) 07

Re: [algogeeks] Question asked in Tachyon interview

2012-06-27 Thread Amitesh Singh
It can be done using Queues in O(n). -- Amitesh On Wed, Jun 27, 2012 at 3:07 PM, hary rathor harry.rat...@gmail.com wrote: apply BFS -- 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] Question asked in Tachyon interview

2012-06-27 Thread atul anand
queue q; q.enqueue(root); while q is not empty do print :temp=dequeue(); if(temp-left) enqueue(temp-left) if(temp-right) enqueue(temp-right); end while; On Wed, Jun 27, 2012 at 2:59 PM, Gobind Kumar Hembram gobind@gmail.comwrote: Write C code to

[algogeeks] Question asked in Tachyon interview

2012-06-26 Thread Gobind Kumar Hembram
How to multiply two numbers without using * operator? Hint:Use bit operators -- 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] Question asked in Tachyon interview

2012-06-26 Thread atul anand
search for Ethiopian Multiplication On Wed, Jun 27, 2012 at 9:45 AM, Gobind Kumar Hembram gobind@gmail.comwrote: How to multiply two numbers without using * operator? Hint:Use bit operators -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Question asked in Tachyon interview

2012-06-26 Thread Prateek Jain
main(a,b,m) 02{ 03while (~scanf(%d%d,a,b)) 04{ 05 m=0; 06 while (a) 07 { 08if (a1) 09 m+=b; 10a=1; 11b=1; 12 } 13 printf(%d\n,m); 14} 15} -- You received this message

[algogeeks] Question asked in Amazon online test

2012-06-23 Thread Gobind Kumar Hembram
Given an array containing sequence of bits (0 or 1), you have to sort this array in the ascending order i.e. all 0' in first part of array followed by all 1's. The constraints is that you can swap only the adjacent elements in the array. Find the minimum number of swaps required to sort the

Re: [algogeeks] Question asked in Amazon Online test

2012-06-23 Thread Guruprasad Sridharan
Let u and r be the distance to move in the up and right directions. u=y2-y1 and r=x2-x1. We have to move a total of u+r units. So the answer would be (u+r)!/u!r! since we are counting only the distinct paths. Each path from (x1,y1) to (x2,y2) may be expressed as a sequence of u+r steps

Re: [algogeeks] Question asked in Amazon online test

2012-06-23 Thread Guruprasad Sridharan
Use a merge sort like procedure to count the number of inversions such that 0 appears after 1. On Sat, Jun 23, 2012 at 11:34 AM, Gobind Kumar Hembram gobind@gmail.com wrote: Given an array containing sequence of bits (0 or 1), you have to sort this array in the ascending order i.e. all 0'

Re: [algogeeks] Question asked in Amazon online test

2012-06-23 Thread Gobind Kumar Hembram
If we use merge sort like procedure,ans will be 1 here it should be 3.we have to swap 0s and 1s linearly. -- 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] Question asked in Amazon online test

2012-06-23 Thread Guruprasad Sridharan
We need to sort as we count the inversions. On Sat, Jun 23, 2012 at 11:56 AM, Gobind Kumar Hembram gobind@gmail.com wrote: If we use merge sort like procedure,ans will be 1 here it should be 3.we have to swap 0s and 1s linearly. -- You received this message because you are subscribed

Re: [algogeeks] Question asked in Amazon Online test

2012-06-23 Thread Kumar Vishal
bcaz choosing any vertical will automatically fix the horizontals and vice verse (u+r) C r= (u+r) C u On Sat, Jun 23, 2012 at 1:08 PM, Kumar Vishal kumar...@gmail.com wrote: Let u and r be the distance to move in the up and right directions. u=y2-y1 and r=x2-x1. (u+r) C r On

Re: [algogeeks] Question asked in Amazon Online test

2012-06-23 Thread Kumar Vishal
Let u and r be the distance to move in the up and right directions. u=y2-y1 and r=x2-x1. (u+r)Cr On Sat, Jun 23, 2012 at 11:40 AM, Guruprasad Sridharan sridharan.mi...@gmail.com wrote: Let u and r be the distance to move in the up and right directions. u=y2-y1 and r=x2-x1. We have to

[algogeeks] Question

2012-06-23 Thread Gobind Kumar Hembram
Write a function longest_palindrome, which takes an array of strings as argument and returns the longest palindrome in that array if any.Please give ideas how to implement this function. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

[algogeeks] Question asked in Amazon Online test

2012-06-22 Thread Gobind Kumar Hembram
Given two positions in a 2-D matrix, say (x1, y1) and (x2, y2) where x2=x1 and y2=y1. Find the total number of distinct paths between (x1, y1) and (x2, y2). You can only move in right direction i.e. positive x direction (+1, 0) or in up direction i.e. positive y direction (0, +1) from any given

[algogeeks] Question

2012-06-22 Thread Gobind Kumar Hembram
Given an integer expression in a prefix format (i.e. the operator precedes the number it is operating on) , print the expression in the post fix format . Example: If the integer expression is in the prefix format is *+56-78, the postfix format expression is 56+78-*. Both of these correspond to

[algogeeks] question

2011-09-21 Thread prasanth n
You have given a positive number you have to find a number which is bigger than that by using same digits available in the number . Example :- You have given a number 7585 , your output should be 7855 . -- *prasanth* -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] question

2011-09-21 Thread kartik sachan
http://ideone.com/xRnDo # includestdio.h# includestring.hvoid findbig(char *a){ int i,j; int flag=0; for(i=strlen(a)-1;i0;i--) if(a[i-1]a[i]) { char temp=a[i]; a[i]=a[i-1]; a[i-1]=temp; flag=1;

[algogeeks] Question --

2011-09-20 Thread Ishan Aggarwal
You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- Kind

Re: [algogeeks] Question --

2011-09-20 Thread abhinav gupta
I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit

Re: [algogeeks] Question --

2011-09-20 Thread abhinav gupta
U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values. for(k=31;k=0;k++) { N[k]=n 01; M[k]=m 01; n=1; m=1; } for(k=i;k=j;k++) N[k]=M[k]; On Tue, Sep 20, 2011 at 12:44 PM, abhinav gupta

Re: [algogeeks] Question --

2011-09-20 Thread Ishan Aggarwal
What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.comwrote: U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values.

Re: [algogeeks] Question --

2011-09-20 Thread Yogesh Yadav
+1 abhinav but u forgot to change array again into bits... ... On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.com

Re: [algogeeks] Question --

2011-09-20 Thread abhinav gupta
Its because o/p should look like dat.Bt dats simple you can do it by multiplying bits to power(2, i) and adding all expressions.Simple! On Tue, Sep 20, 2011 at 1:09 PM, abhinav gupta guptaabhinav...@gmail.comwrote In the first loop bits are added into the array N and M .I have taken two

Re: [algogeeks] Question --

2011-09-20 Thread abhinav gupta
In the first loop bits are added into the array N and M .I have taken two integers n and m . Caution : declare int N[31]={0}; int M[31]={0}; int n,m,i,j; On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31

Re: [algogeeks] Question --

2011-09-20 Thread abhinav gupta
You can also solve the problem by using bit operators. by using| ! . Need sm thinking in dat..No time rite nw! On Tue, Sep 20, 2011 at 1:12 PM, abhinav gupta guptaabhinav...@gmail.comwrote: Its because o/p should look like dat.Bt dats simple you can do it by multiplying bits to power(2, i)

Re: [algogeeks] Question --

2011-09-20 Thread surender sanke
t = j-i+1; // total number bits (t) between i and j , i=2,j=6 t = 2^t-1; // value would be 2^5-1 .. 0001 t = ~t ;// ...1110 t = ti | 2^i-1 // 1000 0011 N = N t; // resets all bits between i and j to 0 in N N = N | Mi; sets bits in N with bits in M surender

[algogeeks] question on algorithm

2011-09-16 Thread prasanth n
Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n cents. also do give an algorithm first.. -- *prasanth* -- You received this message because you are subscribed to the Google

Fwd: [algogeeks] Question -- plz answer

2011-09-12 Thread t.yogendra nath babu babu
If u have any questions like please post in this forum www.buddysforum.com -- Forwarded message -- From: Ishan Aggarwal ishan.aggarwal.1...@gmail.com Date: Sat, Sep 10, 2011 at 8:10 PM Subject: [algogeeks] Question -- plz answer To: algogeeks@googlegroups.com 1

[algogeeks] Question -- plz answer

2011-09-10 Thread Ishan Aggarwal
1.) there is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on.. It looks something like this 1 2 3 4 5 6 every cup has capacity C. you pour L liters of water from top . when cup 1 gets filled , it overflows to cup 2,3 equally, and when they get filled , Cup 4 and 6 get water

Re: [algogeeks] Question -- plz answer

2011-09-10 Thread bharatkumar bagana
what is M? On Sat, Sep 10, 2011 at 8:10 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: 1.) there is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on.. It looks something like this 1 2 3 4 5 6 every cup has capacity C. you pour L liters of water from top .

[algogeeks] question in C

2011-08-24 Thread sadhana kumar
Can anyone explain this code pls?? #include stdio.h #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() { printf(%s\n,h(f(1,2))); printf(%s\n,g(f(1,2))); return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] question on fork()

2011-08-22 Thread dexter does
void red() { } void green() { } main() { fork(); int color=fork(); if(color==0) fork(); red(); if(color==0) fork(); green(); getch(); } How many times red and green are called and pls give an explanation for your

Re: [algogeeks] question to code

2011-08-22 Thread tanuj chawla
@sanjay - shouldnt we use count instead of second k. and when count becomes size/2,we get the element becouse we dont know the array in which that element resides correct me if m wrong?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

Re: [algogeeks] question to code

2011-08-22 Thread Sanjay Rajpal
in the solution I proposed, k is doing the job of count. I think u should look at it again. Sanju :) On Mon, Aug 22, 2011 at 1:42 AM, tanuj chawla houndhun...@gmail.com wrote: @sanjay - shouldnt we use count instead of second k. and when count becomes size/2,we get the element becouse

Re: [algogeeks] question on fork()

2011-08-22 Thread ghsjgl k
i saw this question in one of DREAM companies i dont know the answer On Mon, Aug 22, 2011 at 11:43 AM, dexter does dxterd...@gmail.com wrote: void red() { } void green() { } main() { fork(); int color=fork(); if(color==0) fork(); red();

[algogeeks] question to code

2011-08-21 Thread vaibhav shukla
given three sorted arrays not necessary of same length (length is given) we have to determine the middle element such that the element will be the middle one of the such an array which will be formed if all three given arrays are merged in sorted order. input :- arr1 : 1,3,5,7 arr2

Re: [algogeeks] question to code

2011-08-21 Thread Puneet Chawla
Here by just applying merge on these array as they are sorted and calculate the middle element..Am i rt..??? On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla vaibhav200...@gmail.comwrote: given three sorted arrays not necessary of same length (length is given) we have to determine the middle

Re: [algogeeks] question to code

2011-08-21 Thread Sanjay Rajpal
Take three pointers to the beginning of each array say i,j,k. Now let sum = len a +len b + len c. k=0 now start from the beginning, compare elements at indexes i,j,k. which ever is smaller, increment that index and k, continue till k becomes sum/2. when k becomes sum/2, this element will be

Re: [algogeeks] question to code

2011-08-21 Thread vaibhav shukla
@puneet : but u cant use extra memory On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.com wrote: Take three pointers to the beginning of each array say i,j,k. Now let sum = len a +len b + len c. k=0 now start from the beginning, compare elements at indexes i,j,k. which ever

Re: [algogeeks] question to code

2011-08-21 Thread Puneet Chawla
ohh sryy i didn't read tht On Sun, Aug 21, 2011 at 11:09 PM, vaibhav shukla vaibhav200...@gmail.comwrote: @puneet : but u cant use extra memory On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.com wrote: Take three pointers to the beginning of each array say i,j,k. Now let

Re: [algogeeks] question to code

2011-08-21 Thread vaibhav shukla
@sanjay : yes this is one approach . just doing this and keeping track of the smaller element and wen k is sum/2, the minimum element of the middle on true. but any other approach apart from this and wat if the total length is even, i.e u have to give two middle elements then On Sun, Aug 21,

Re: [algogeeks] question to code

2011-08-21 Thread Puneet Chawla
@sanjay why you have compared k with sum/2 is it a general solution..??? On Sun, Aug 21, 2011 at 11:11 PM, vaibhav shukla vaibhav200...@gmail.comwrote: @sanjay : yes this is one approach . just doing this and keeping track of the smaller element and wen k is sum/2, the minimum element of the

Re: [algogeeks] question to code

2011-08-21 Thread Sanjay Rajpal
see sum is total no.of elements in three arrays. the question is middle element in the merged array. so the middle element would be at index sum/2. Sanju :) On Sun, Aug 21, 2011 at 10:46 AM, Puneet Chawla puneetchawla...@gmail.comwrote: @sanjay why you have compared k with sum/2 is it a

Re: [algogeeks] question to code

2011-08-21 Thread Sanjay Rajpal
http://stackoverflow.com/questions/6182488/median-of-5-sorted-arrays this link will help m damn sure. Sanju :) On Sun, Aug 21, 2011 at 10:48 AM, Sanjay Rajpal srn...@gmail.com wrote: see sum is total no.of elements in three arrays. the question is middle element in the merged array. so

Re: [algogeeks] Question from Google interview

2011-08-19 Thread arun kumar
Build a Trie... Recursive search on trie This ll give you all possible interpretation of the given key On 8/18/11, Navneet Gupta navneetn...@gmail.com wrote: Given a string containing multiple words such that spaces between words is missing. Also, you have a dictionary containing valid

Re: [algogeeks] Question from Google interview

2011-08-19 Thread priya ramesh
Hash in the dictionary for the first letter in the string. Check if any word in the dictionary beginning with this letter is a substring of the given string. If yes and if the substring forms the initial part of the string, tokenize it. Continue the process with the next word. -- You received

[algogeeks] Question from Google interview

2011-08-18 Thread Navneet Gupta
Given a string containing multiple words such that spaces between words is missing. Also, you have a dictionary containing valid words. Ex. Thatwouldbefantastic Output a string with proper spaces inserted. Output - That would be fantastic The case of words like bandwidth present can be

Re: [algogeeks] Question from Google interview

2011-08-18 Thread aditya kumar
not sure abt the algo but we can think in terms of tokeninzing . ie go for greedy method . greedy looks for maximum match . extract the token and match with the dictionary word . if match found then add the additional space else look for next token . On Thu, Aug 18, 2011 at 9:10 PM, Navneet Gupta

[algogeeks] Question

2011-08-06 Thread UTKARSH SRIVASTAV
CAN ANYONe PLEASE TELL ME WHICH TEST CASE I AM GETTING WRONG I HAVE TRIED ALL WHICH I COULD TRY IN THIS PROBLEM http://www.spoj.pl/problems/M00PAIR/ MY SOLUTION -- #includestdio.h #includestring.h int fun(char *s) { int i,n; for(i=0;s[i]!='\0';i++);

Re: [algogeeks] Question

2011-08-06 Thread saurabh singh
You are taking string as a variable when a simple int would do...:) check your fun() function otherwise i got AC with same idea as u have used On Sat, Aug 6, 2011 at 4:40 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: CAN ANYONe PLEASE TELL ME WHICH TEST CASE I AM GETTING WRONG

[algogeeks] question

2011-08-06 Thread UTKARSH SRIVASTAV
difference between 64-bit compiler and 64-bit operating system..sizeof any data type depends on compiler or operating system -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] question

2011-08-06 Thread hary rathor
in a 64 bit computer is that is capable of transfer 64 bit at a time 64 bit os means it capable of handle these 64 bit at time .but 32 it os use only half of bus so theorytically not practically 64 bit is 8 time faster than 32 bit os . and 64 bit os can address more ram at time . cause of wide 64

[algogeeks] Question

2011-08-05 Thread Vijay Khandar
What errors are you likely to get when you run the following program? #includestdio.h #includeconio.h #includestring.h void main() { clrscr(); struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0;i=3;i++) scanf(%s %f,e[i].name,e[i].sal); getch(); } Plz Explain

Re: [algogeeks] Question

2011-08-05 Thread Nikhil Gupta
Couldn't find any error. On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What errors are you likely to get when you run the following program? #includestdio.h #includeconio.h #includestring.h void main() { clrscr(); struct emp { char name[20]; float sal;

[algogeeks] Question

2011-08-05 Thread Vijay Khandar
What errors are you likely to get when you run the following program? #includestdio.h #includeconio.h #includestring.h void main() { clrscr(); struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0;i=3;i++) scanf(%s %f,e[i].name,e[i].sal); getch(); } A)floating point format

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
But program is not working properly... On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Couldn't find any error. On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What errors are you likely to get when you run the following

Re: [algogeeks] Question

2011-08-05 Thread Nikhil Gupta
http://www.ideone.com/ZIibX The changes I have done in the program are to make it compatible to gcc compiler. Check the statement in the bottom of the page. On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What errors are you likely to get when you run the following

Re: [algogeeks] Question

2011-08-05 Thread SANDEEP CHUGH
ITS (A). BECAUSE WE HAVE TO LINK THE EMULATOR AS COMPILER SEES A REFERENCE TO FLOATING POINT NUMBER IT SETS ITS FLAG TO HAVE THE LINKER LINK INT THE EMULATOR.. ITS IN 16 BIT COMPILER BECAUSE THERE IS NO PROVISION FOR FLOATING POINT OPERATIONS IN 16 BIT MICRO PROCESSOR..SO THEY USE FLOATING POINT

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
But program is not giving the o/p. I have taken one printf statement same as scanf..and scanf() taking i/p but prinf() not giving o/p... On Fri, Aug 5, 2011 at 5:53 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: http://www.ideone.com/ZIibX The changes I have done in the program are to

Re: [algogeeks] Question

2011-08-05 Thread SANDEEP CHUGH
INCLUDE THIS FUNCTION linkfloat( ) { float a = , *b ; b = a ; /* cause emulator to be linked */ a = *b ;/* suppress the warning - variable not used */ }; On Fri, Aug 5, 2011 at 6:04 PM, Vijay Khandar vijaykhand...@gmail.comwrote: But program is not giving the o/p. I have taken one printf

Re: [algogeeks] Question

2011-08-05 Thread Dipankar Patro
try doing this way and tell if the program is working properly now: for (i=0; i3; i++) { scanf(%[^\n], e[i].name); scanf(%f, e[i].sal); } There is always some problem in string input using %s, don't really know why though deeply. On 5 August 2011 17:48, Vijay Khandar vijaykhand...@gmail.com

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
I include this fn linkfloat(), Now my program working properlybut why we have to include this fn externally plz explain. On Fri, Aug 5, 2011 at 6:07 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: INCLUDE THIS FUNCTION linkfloat( ) { float a = , *b ; b = a ; /* cause

Re: [algogeeks] Question

2011-08-05 Thread Rohit Srivastava
you might get error: floating pointing formats not linked!! but thats obsolete! I don't compiler these days will give such an error otherwise code written by Dipankar will solve ur problem if u r unable to take multi-word input On Fri, Aug 5, 2011 at 7:24 PM, Dipankar Patro dip10c...@gmail.com

Re: [algogeeks] Question

2011-08-05 Thread Rohit Srivastava
which compiler are u using ? On Fri, Aug 5, 2011 at 7:29 PM, Vijay Khandar vijaykhand...@gmail.comwrote: I include this fn linkfloat(), Now my program working properlybut why we have to include this fn externally plz explain. On Fri, Aug 5, 2011 at 6:07 PM, SANDEEP CHUGH

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
Yes correct, In m using very old compiler Turbo C++ On Fri, Aug 5, 2011 at 7:34 PM, Rohit Srivastava access2ro...@gmail.comwrote: you might get error: floating pointing formats not linked!! but thats obsolete! I don't compiler these days will give such an error otherwise code written by

Re: [algogeeks] Question

2011-08-05 Thread Rohit Srivastava
try using dev or any new 32bit compiler it wont give that error!!! or try using this void linkfloat(void) { float a=0,*b=a; a=*b; } this code forces the emulator to be linked On Fri, Aug 5, 2011 at 7:38 PM, Vijay Khandar vijaykhand...@gmail.comwrote: Yes correct, In m using very old

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
Yes due to this only i m getting proper o/p, but why it is necessary in Turbo C++ compiler.? On Fri, Aug 5, 2011 at 7:41 PM, Rohit Srivastava access2ro...@gmail.comwrote: try using dev or any new 32bit compiler it wont give that error!!! or try using this void linkfloat(void) {

[algogeeks] question

2011-07-28 Thread sylvester
Given two integers A B. Determine how many bits required to convert A to B. Write a function int BitSwapReqd(int A, int B); -- 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] question

2011-07-28 Thread Rajeshwar Patra
just perform the xor operation on A and B the number of 1's give the no of bits required... Correct me if i am wrong -- 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

[algogeeks] Question

2011-07-27 Thread Vijay Khandar
#includestdio.h #includeconio.h void main() { clrscr(); int x=1,y=1,z=1; x+=y+=z; printf(\n %d\n ,xy?y:x); printf(\n %d\n,xy?x++:y++); printf(\n %d %d\n,x,y); printf(\n %d\n,z+=xy?x++:y++); printf(\n %d %d %d\n,x,y,z); x=3;y=z=4; printf(\n %d\n,z=y=x?1:0); printf(\n %d\n,z=yy=x); getch(); } I m

Re: [algogeeks] Question

2011-07-27 Thread aditi garg
C i guess ur comfortable wid the frst 3... now in fourth c the order of evaluation frst xy is evaluated as has higher precedence that +=...since both r 3...so condition is false and y++ is taken...so z+=y++ takes place... z ws 1 and y=3...so z becomes 4 and it is printed... and after this y

Re: [algogeeks] Question

2011-07-27 Thread Janet Bernosky
How can I stop getting emails from this group  I went on your site to look up one thing, and now I am getting all this STUFF I don't want...Please help... --- On Wed, 7/27/11, aditi garg aditi.garg.6...@gmail.com wrote: From: aditi garg aditi.garg.6...@gmail.com Subject: Re: [algogeeks

Re: [algogeeks] Question

2011-07-27 Thread SkRiPt KiDdIe
use unsubscribe link at bottom of mail. -- 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

[algogeeks] Question

2011-07-25 Thread sagar pareek
A man leaves office daily at 7pm.a driver with car comes from his home to pick him from office and bring back home. One day he gets free at 5.30 and instead of waiting for driver he starts walking towards home. In the wayhe meets the car and returns home on car. He reaches home 20 minutes earlier

Re: [algogeeks] Question

2011-07-25 Thread AASHISH SUMAN
@sagar :: this group is for programming concepts not for apti.. if u wana to post some apti or reasoning question post here.. http://www.facebook.com/groups/150933398312351?ap=1 -- *WITH BEST REGARDS : AASHISH SUMAN MCA FINAL YEAR * *NIT DURGAPUR* *+91-9547969906* -- You received this

Re: [algogeeks] Question

2011-07-25 Thread shady
easy guys... @sagar nice question, if there had been an option for incomplete info, i would have gone with that... but it made me think thoroughly :) 80 min. is answer @aashish we are forming new group for apti kind of questions... On Mon, Jul 25, 2011 at 10:23 PM, AASHISH SUMAN

  1   2   >