Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-24 Thread immanuel kingston
@sravan, What i meant was get the jth digit in the representation of i to the base NUM_PER_DIGIT. ie 3rd digit of (2137)8 which is 2.. 7 is the 0th digit, 3 being 1st digit, 1 being 2nd digit and 2 being 3rd digit.Here 2137 is a base 8 representation. Thanks, Immanuel On Tue, May 24, 2011 at 6:37

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-24 Thread sravanreddy001
@Immanuel: In the iteretive approach, can you tell me what you meant by this function. A code is not required, but, how are we going to calculate? the method name is little confusing. The recursive is good.. but.. I'm looking at the iterative approach. ---> getJthDigitinItotheBaseNumPerDigit(N

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread immanuel kingston
@Anuj, true.This will optimise the solution by reducing the amount of stack space used for recursion. NUM_PER_DIGIT = 3 char c[][NUM_PER_DIGIT] = {"abc","def",...}; char n[] = 2156169 (number is pressed); int k=7; char * s = (char *) malloc(sizeof(char) * k); void printAllCombinations (int k, c

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread anuj agarwal
Immanuel, We can keep c and n arrays as global variable as they are not part of state of the recursion. Anuj Agarwal Engineering is the art of making what you want from things you can get. On Mon, May 23, 2011 at 10:04 PM, immanuel kingston < kingston.imman...@gmail.com> wrote: > small correcti

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread immanuel kingston
small correction On Mon, May 23, 2011 at 9:46 PM, immanuel kingston < kingston.imman...@gmail.com> wrote: > A Recursive soln: > > > NUM_PER_DIGIT = 3 > char c[][NUM_PER_DIGIT] = {"abc","def",...}; > > char n[] = 2156169 (number is pressed); > int k=7; > char * s = (char *) malloc(sizeof(char) * k

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread immanuel kingston
A Recursive soln: NUM_PER_DIGIT = 3 char c[][NUM_PER_DIGIT] = {"abc","def",...}; char n[] = 2156169 (number is pressed); int k=7; char * s = (char *) malloc(sizeof(char) * k); void printAllCombinations (char c[][], char n[], int k, char *s, int count) { if (count >= k - 1) { s[k] = '

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread immanuel kingston
Extending the above soln: NUM_PER_DIGIT = 3 char c[][NUM_PER_DIGIT] = {"abc","def",...}; char n[] = 2156169 (number is pressed); int k=7; for i <-- 0 to NUM_PER_DIGIT ^ k String s=""; for j <-- 0 to k int index = getJthDigitinItotheBaseNumPerDigit(NUM_PER_DIGIT,i,j); // ie get 1s

Re: [algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread anshu mishra
the same question i have asked in microsoft interview. (if it is the same :P) for 12 perutation are (ad, ae, af, bd, be, bf, cd, ce ,cf); i have given them 3 solution(recusrsive, stack based) and the last one what they wanted. take a tertiary number(n) = 3^(number of digits) in case of 12 it is e

[algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread Dumanshu
I didn't get the question actually. I have copied the post(the question). but i dont think for 12, 36 can be the answer. We have to go for the permutation of the telephone number i guess after substituting for each number the corresponding set of alphabets. The question given is - "Given a telephon