[algogeeks] Re: [Adobe]Generate all possible combinations (of r elements) inside an array of size N

2014-02-27 Thread Ziklon
1.- if you use bitmask can be easy solved
2.- second aproach is create un recursion

string func(int idx, int cnt){
   if(cnt==r)return ;;
   string ans = func(idx+1, cnt);
   if(cntr) ans = ans+\n + func(idx+1, cnt+1) + a[idx];
  return ans;
}






On Sunday, May 19, 2013 10:08:10 AM UTC-5, rahul sharma wrote:

  Generate all possible combinations (of r elements) inside an array of 
 size N
 E.g. arr [] = {2,8,14} All possible combinations of r=2 will be {2,8}, 
 {8,14}, {14,2}

 Asked in adobe


-- 
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 an email 
to algogeeks+unsubscr...@googlegroups.com.


[algogeeks] Re: adobe apti question

2012-12-18 Thread Don
I would say that (c) is the correct answer.
III is the only one which MUST be true. We also know that I xor II
will be true, but that is not what option (e) says.
Don

On Dec 16, 12:48 pm, rahul sharma rahul23111...@gmail.com wrote:
 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-B    then B-fg   and D    else if A-C   ,then   c-eh and c-d

 am i ryt

-- 




Re: [algogeeks] Re: adobe apti question

2012-12-17 Thread Shubham Sandeep
agreed

On Mon, Dec 17, 2012 at 10:03 AM, marti amritsa...@gmail.com wrote:

 Yes Rahul Sharma. you are right. the ans is 1and3 or 2and3


 On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote:

 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-Bthen B-fg   and Delse if A-C   ,then   c-eh and c-d

 am i ryt

  --






-- 
Regards,
SHUBHAM SANDEEP
IT 3rd yr.
NIT ALD.

-- 




[algogeeks] Re: Adobe Interview Question

2012-12-16 Thread Devendra Singh
Problem 2) of generating permutations from a string was asked to me in 
Virtusa Tech Interview

On Sunday, December 9, 2012 3:22:19 PM UTC+5:30, manish untwal wrote:

 I gave this interview in August this year, two of the question i was not 
 able to answer properly
 1) how to print the content of file in C without using the file pointer.
 2) count the total number of permutation of a number in order O(n)


-- 




[algogeeks] Re: adobe apti question

2012-12-16 Thread marti
Yes I feel (e) is the right option.

On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote:

 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-Bthen B-fg   and Delse if A-C   ,then   c-eh and c-d

 am i ryt


-- 




Re: [algogeeks] Re: adobe apti question

2012-12-16 Thread Shubham Sandeep
according to me option c holds
Reason:it is either that FG or EH pair occurs but both pairs cannot occur
as one is an oucome of B while other holds if C occurs. since either B or C
(but not both) may follow A... so point prooved. but D will always be there
weather B or C follows after A.
since must occur is asked my answer is option C

On Sun, Dec 16, 2012 at 11:39 PM, marti amritsa...@gmail.com wrote:

 Yes I feel (e) is the right option.


 On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote:

 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-Bthen B-fg   and Delse if A-C   ,then   c-eh and c-d

 am i ryt

  --






-- 
Regards,
SHUBHAM SANDEEP
IT 3rd yr.
NIT ALD.

-- 




Re: [algogeeks] Re: adobe apti question

2012-12-16 Thread rahul sharma
I got it from aomewhr .answer given is e...
E option is wrng as per my opinion..
It should be 13 or 23 instead of 12or23

am i ryt?

On Mon, Dec 17, 2012 at 12:03 AM, Shubham Sandeep 
s.shubhamsand...@gmail.com wrote:

 according to me option c holds
 Reason:it is either that FG or EH pair occurs but both pairs cannot
 occur as one is an oucome of B while other holds if C occurs. since either
 B or C (but not both) may follow A... so point prooved. but D will always
 be there weather B or C follows after A.
 since must occur is asked my answer is option C


 On Sun, Dec 16, 2012 at 11:39 PM, marti amritsa...@gmail.com wrote:

 Yes I feel (e) is the right option.


 On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote:

 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-Bthen B-fg   and Delse if A-C   ,then   c-eh and c-d

 am i ryt

  --






 --
 Regards,
 SHUBHAM SANDEEP
 IT 3rd yr.
 NIT ALD.

  --




-- 




[algogeeks] Re: adobe apti question

2012-12-16 Thread marti
Yes Rahul Sharma. you are right. the ans is 1and3 or 2and3

On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote:

 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-Bthen B-fg   and Delse if A-C   ,then   c-eh and c-d

 am i ryt


-- 




Re: [algogeeks] Re: Adobe Interview Question

2012-12-13 Thread saurabh singh
^ *Exactly,* Things are the *same all around the globe *in terms of
hiring procedure for programming positions. However I don't understand *this
is India  *part?
Kindly reply only *when you think you are contributing something to the
community.*

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Dec 13, 2012 at 10:27 AM, rahul rahulr...@gmail.com wrote:

 @don , becoz this is India...and shit happens everywhere


 On Wed, Dec 12, 2012 at 11:48 PM, Don dondod...@gmail.com wrote:

 I dislike interview questions which place arbitrary restrictions on
 the solver.
 It may be a good puzzle, but it's not a good interview question.

 Print the numbers 1 to 100 without using a loop.

 Why would you want to do that?

 Divide a number by 5 without using the divide operator.

 Again, why? Interview questions shouldn't be about silly little
 tricks, but about showing that you can do a real-world job.

 Don

 On Dec 11, 10:23 pm, saurabh singh saurab...@gmail.com wrote:
  I would have replied back with I am doing it with C programming language
  only. the read function that we use is not an actual system call. It
  is a *wrapper
  to a system call*. Any other function that we use usually ends up in
  calling some system call. The actual system call is called by low level
  routines.
  If he still disagreed I would have given him this solution:
 
  #includestdio.h
  int main()
  {
  int ch;
  while((ch=getchar())!=-1) putchar(ch);
  return 0;
 
  }
 
  Would have run this as *./a.out  file_to_read*
  *
  *
  If he still disagreed I would have walked out :P
 
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Tue, Dec 11, 2012 at 11:23 PM, manish untwal 
 manishuntw...@gmail.comwrote:
 
 
 
 
 
 
 
   i answered with the...system call too..but he said...do it in C
   programming language only don't use...system call here!!
 
   On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh saurab...@gmail.com
 wrote:
 
   stdin is a file pointer.
   freopen returns a file pointer..
   I suggest using read system call.
 
   For the second question it would be simply
   (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)
 
   However this will also contains permutations which begin with 0. So
   subtract the number of permutations that begin with 0 from this
 number.
 
   Since any factorial in the denominator part will be less than or
 equal to
   (len)! we can calculate and store them while calculating len! Hence
 the
   overall operation will take O(len) time which would be O(log n)
 where n is
   the number.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Tue, Dec 11, 2012 at 11:02 AM, amrit harry 
 dabbcomput...@gmail.comwrote:
 
   1st:
 
   freopen(filename,r,stdin);
 
   while(scanf(%s,str)!=-1)
   {
   printf(%s\n,str);
   }
 
   On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
 manishuntw...@gmail.comwrote:
 
   I gave this interview in August this year, two of the question i
 was
   not able to answer properly
   1) how to print the content of file in C without using the file
 pointer.
   2) count the total number of permutation of a number in order O(n)
 
   --
 
   --
   Thanks  Regards
   Amritpal singh
 
--
 
--
 
   --
   With regards,
   Manish kumar untwal
   Indian Institute of Information Technology
   Allahabad (2009-2013 batch)
 
--

 --



  --




-- 




[algogeeks] Re: Adobe Interview Question

2012-12-12 Thread Don
I dislike interview questions which place arbitrary restrictions on
the solver.
It may be a good puzzle, but it's not a good interview question.

Print the numbers 1 to 100 without using a loop.

Why would you want to do that?

Divide a number by 5 without using the divide operator.

Again, why? Interview questions shouldn't be about silly little
tricks, but about showing that you can do a real-world job.

Don

On Dec 11, 10:23 pm, saurabh singh saurab...@gmail.com wrote:
 I would have replied back with I am doing it with C programming language
 only. the read function that we use is not an actual system call. It
 is a *wrapper
 to a system call*. Any other function that we use usually ends up in
 calling some system call. The actual system call is called by low level
 routines.
 If he still disagreed I would have given him this solution:

 #includestdio.h
 int main()
 {
 int ch;
 while((ch=getchar())!=-1) putchar(ch);
 return 0;

 }

 Would have run this as *./a.out  file_to_read*
 *
 *
 If he still disagreed I would have walked out :P

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com

 On Tue, Dec 11, 2012 at 11:23 PM, manish untwal 
 manishuntw...@gmail.comwrote:







  i answered with the...system call too..but he said...do it in C
  programming language only don't use...system call here!!

  On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh saurab...@gmail.comwrote:

  stdin is a file pointer.
  freopen returns a file pointer..
  I suggest using read system call.

  For the second question it would be simply
  (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)

  However this will also contains permutations which begin with 0. So
  subtract the number of permutations that begin with 0 from this number.

  Since any factorial in the denominator part will be less than or equal to
  (len)! we can calculate and store them while calculating len! Hence the
  overall operation will take O(len) time which would be O(log n) where n is
  the number.

  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com

  On Tue, Dec 11, 2012 at 11:02 AM, amrit harry 
  dabbcomput...@gmail.comwrote:

  1st:

  freopen(filename,r,stdin);

  while(scanf(%s,str)!=-1)
  {
  printf(%s\n,str);
  }

  On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
  manishuntw...@gmail.comwrote:

  I gave this interview in August this year, two of the question i was
  not able to answer properly
  1) how to print the content of file in C without using the file pointer.
  2) count the total number of permutation of a number in order O(n)

  --

  --
  Thanks  Regards
  Amritpal singh

   --

   --

  --
  With regards,
  Manish kumar untwal
  Indian Institute of Information Technology
  Allahabad (2009-2013 batch)

   --

-- 




Re: [algogeeks] Re: Adobe Interview Question

2012-12-12 Thread rahul
@don , becoz this is India...and shit happens everywhere

On Wed, Dec 12, 2012 at 11:48 PM, Don dondod...@gmail.com wrote:

 I dislike interview questions which place arbitrary restrictions on
 the solver.
 It may be a good puzzle, but it's not a good interview question.

 Print the numbers 1 to 100 without using a loop.

 Why would you want to do that?

 Divide a number by 5 without using the divide operator.

 Again, why? Interview questions shouldn't be about silly little
 tricks, but about showing that you can do a real-world job.

 Don

 On Dec 11, 10:23 pm, saurabh singh saurab...@gmail.com wrote:
  I would have replied back with I am doing it with C programming language
  only. the read function that we use is not an actual system call. It
  is a *wrapper
  to a system call*. Any other function that we use usually ends up in
  calling some system call. The actual system call is called by low level
  routines.
  If he still disagreed I would have given him this solution:
 
  #includestdio.h
  int main()
  {
  int ch;
  while((ch=getchar())!=-1) putchar(ch);
  return 0;
 
  }
 
  Would have run this as *./a.out  file_to_read*
  *
  *
  If he still disagreed I would have walked out :P
 
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Tue, Dec 11, 2012 at 11:23 PM, manish untwal manishuntw...@gmail.com
 wrote:
 
 
 
 
 
 
 
   i answered with the...system call too..but he said...do it in C
   programming language only don't use...system call here!!
 
   On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh saurab...@gmail.com
 wrote:
 
   stdin is a file pointer.
   freopen returns a file pointer..
   I suggest using read system call.
 
   For the second question it would be simply
   (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)
 
   However this will also contains permutations which begin with 0. So
   subtract the number of permutations that begin with 0 from this
 number.
 
   Since any factorial in the denominator part will be less than or
 equal to
   (len)! we can calculate and store them while calculating len! Hence
 the
   overall operation will take O(len) time which would be O(log n) where
 n is
   the number.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Tue, Dec 11, 2012 at 11:02 AM, amrit harry 
 dabbcomput...@gmail.comwrote:
 
   1st:
 
   freopen(filename,r,stdin);
 
   while(scanf(%s,str)!=-1)
   {
   printf(%s\n,str);
   }
 
   On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
 manishuntw...@gmail.comwrote:
 
   I gave this interview in August this year, two of the question i was
   not able to answer properly
   1) how to print the content of file in C without using the file
 pointer.
   2) count the total number of permutation of a number in order O(n)
 
   --
 
   --
   Thanks  Regards
   Amritpal singh
 
--
 
--
 
   --
   With regards,
   Manish kumar untwal
   Indian Institute of Information Technology
   Allahabad (2009-2013 batch)
 
--

 --




-- 




[algogeeks] Re: adobe question

2012-10-21 Thread apsalar
You could update fibb[n] before returning fib(n-1) + fib(n-2)

int fib(int n)
{
   if ( n = 1 )
   {
fibb[1]=n;
   return n;
  }
  
if (fibb[n] ! = 0 ) {

 //return fibs(n-1)+fibs(n-2);
 

   }


On Sunday, October 21, 2012 7:46:43 AM UTC-4, rahul sharma wrote:

 #includestdio.h
  int fib(int n)
  {
 if ( n = 1 )
return n;
 return fib(n-1) + fib(n-2);
  }
   
 How can we reduce no of computations with the above code(iterative 
 solution not allowed).


-- 
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/-/AgmaPZ-P3DIJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe question

2012-10-21 Thread apsalar
You could store fibs[n-1] + fibs[n-2] in fibb[n] before returning.

int fib(int n)
{
   if ( n = 1 )
   {
fibb[1]=n;
   return n;
  }
  
   if(fibb[n] != 0) {
  return fibb[n];
   }
  fibb[n] = fibs[n-1] + fibs[n-2];
  return fibb[n];

 //return fibs(n-1)+fibs(n-2);
 
 }

Thanks

On Sunday, October 21, 2012 7:46:43 AM UTC-4, rahul sharma wrote:

 #includestdio.h
  int fib(int n)
  {
 if ( n = 1 )
return n;
 return fib(n-1) + fib(n-2);
  }
   
 How can we reduce no of computations with the above code(iterative 
 solution not allowed).


-- 
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/-/ev___7tyzPgJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe question

2012-10-21 Thread Jaspreet Singh
here's an O(lgn) soln :
matrix form of fib :
http://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form
and then use the divide and conquer for calculating (A)^n in O(lgn).

Thanks

On Sun, Oct 21, 2012 at 7:10 PM, rahul sharma rahul23111...@gmail.comwrote:

 I have implemented this code below:-
 #includestdio.h
 int fibs(int);
 int fibb[9]={0};
 int fib(int n)
 {
if ( n = 1 )
{
 fibb[1]=n;
return n;
   }

  return fibs(n-1)+fibs(n-2);


}

  int fibs(int n)
  {

  if( fibb[n]!=0)
  return fibb[n];
  int temp=fib(n);
  fibb[n]=temp;
  return temp;


 }



 int main ()
 {
   int n = 9;

   printf(%d, fib(n));
   for(int i=0;i9;i++)
   printf(\n%d,fibb[i]);
   getchar();
   return 0;
 }


 but if i call for 9..then the lookup/fibb should contain upto 9 so that
 when i call for 11 it would take only two computaion..but my code storing
 in fibb upto 8 i.e the element for which we called its result is not
 getting stored in fibbonicci...so if i call for 9 it would store till
 fibb[8].but it should store for 9 also.i am not able to get that
 statemnt...plz correct my code..

 On Sun, Oct 21, 2012 at 6:39 PM, rahul sharma rahul23111...@gmail.comwrote:

 on wiki they are saying(in case of factorial) that once function called
 with 5!..then if we call with 6! then only one iteration neededi just
 wana confirm that both these calls occur simultaneously..i mean like

 fact(5);
 ...
 ...
 ...
 fact(6)


 or
 fact (5).stop execution.add statemet
 fact(6)

 if we do like this this will delete old fact(5) as emmory has been
 deleted after execution..am i ryt??or there is something in memorization
 that preserve the memory


 On Sun, Oct 21, 2012 at 6:32 PM, rahul sharma rahul23111...@gmail.comwrote:

 sachin
 i have no idea about floowong

 Iteratorint, int it = optimizationMap.find(n);

 can you provide me a clear definition

 On Sun, Oct 21, 2012 at 6:30 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 yesi have read somehwr that we can save the already calculated
 values..thtas wat i did.now after ur sol i came to know abput
 memorization..thnx


 On Sun, Oct 21, 2012 at 5:58 PM, Sachin Maheshwari 
 sachin.maheshw...@gmail.com wrote:

 Rahul,
 Your solution in principle is doing a similar work. If you look
 closely you are using fibb array to do memoization of already calculated
 values.

 Regards,
 Sachin

 On Sun, Oct 21, 2012 at 5:47 PM, rahul sharma rahul23111...@gmail.com
  wrote:

  I came up with follwoing solution...plz comment.
 #includestdio.h
 int fib(int n,int fibb[])
 {
if ( n = 1 )
{
 fibb[1]=n;
return n;
   }
   fib(n-1,fibb);
   fibb[n]=fibb[n-1]+fibb[n-2];
   return fibb[n];
 }

 int main ()
 {
   int n = 9;int fibb[9];
   fibb[0]=0;
   printf(%d, fib(n,fibb));
   getchar();
   return 0;
 }

 plz comment
 On Sun, Oct 21, 2012 at 5:16 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 #includestdio.h
  int fib(int n)
  {
 if ( n = 1 )
return n;
 return fib(n-1) + fib(n-2);
  }

 How can we reduce no of computations with the above
 code(iterative solution not allowed).


  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards,
 Sachin Maheshwari
 Cell phone: +91.7259917298

 If we admit that human life can be ruled by reason; the possibility
 of life is destroyed. - Alexander Supertramp

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.





  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe question help

2012-09-13 Thread Navin Gupta
  int temp = {[1(j-+1)]i-1};
  Here temp is a number with all the bits set between positions i  j [both 
inclusive]  
  temp = ~temp;
  N = N  temp;   // here we are clearing all the bits of N from 
position i to j 
  temp = temp | M;   // now we are taking the bit pattern from M into temp  
in the given positions
  N = N | temp;// now again we are setting the same pattern from 
temp into N.

Note :- clearing bit means bit set to zero , while setting bit means bit is 
1

-- 
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/-/QTXreMoSy6gJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe question help

2012-09-13 Thread Ashish Goel
this is from KR exercise :)
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Wed, Sep 12, 2012 at 4:14 PM, Navin Gupta navin.nit...@gmail.com wrote:

   int temp = {[1(j-+1)]i-1};
   Here temp is a number with all the bits set between positions i  j
 [both inclusive]
   temp = ~temp;
   N = N  temp;   // here we are clearing all the bits of N from
 position i to j
   temp = temp | M;   // now we are taking the bit pattern from M into
 temp  in the given positions
   N = N | temp;// now again we are setting the same pattern from
 temp into N.

 Note :- clearing bit means bit set to zero , while setting bit means bit
 is 1


  --
 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/-/QTXreMoSy6gJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2012-07-03 Thread Abhishek Sharma
arr1 = (int *)malloc(sizeof(int) * ncols);// memory allocated for 1st
row
arr2 = (int **)malloc(sizeof(arr1) * nrows);

I haven't tried it.So,please correct me if i am wrong

On Mon, Jul 2, 2012 at 12:55 PM, Rishabh Agarwal rishabh...@gmail.comwrote:


 nrows: number of rows
 ncols: number of columns

 int **arra = (int **)malloc( sizeof(int*) * nrows );
 int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
 for( int a = 0; a  nrows; a ++ ) {
 arra[a] = ar + ncols * a;
 }

 now index of array i and j can be accessed as arra[i][j]



 On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:

 implement a 2d matrix using only 2 mallocs.

  --
 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/-/Pr2cEtta_LsJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2012-07-03 Thread rahul ranjan
@abhishek its wrong as arr1 is just a pointer o int and sizeof(arr1)
will always be 4 bytes(size of a pointer) regardless of number of bytes
allocated to it on heap

On Tue, Jul 3, 2012 at 3:14 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 arr1 = (int *)malloc(sizeof(int) * ncols);// memory allocated for 1st
 row
 arr2 = (int **)malloc(sizeof(arr1) * nrows);

 I haven't tried it.So,please correct me if i am wrong


 On Mon, Jul 2, 2012 at 12:55 PM, Rishabh Agarwal rishabh...@gmail.comwrote:


 nrows: number of rows
 ncols: number of columns

 int **arra = (int **)malloc( sizeof(int*) * nrows );
 int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
 for( int a = 0; a  nrows; a ++ ) {
 arra[a] = ar + ncols * a;
 }

 now index of array i and j can be accessed as arra[i][j]



 On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:

 implement a 2d matrix using only 2 mallocs.

  --
 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/-/Pr2cEtta_LsJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2012-07-03 Thread Abhishek Sharma
what s silly mistake. @Rahul thanks for correcting me.

On Tue, Jul 3, 2012 at 3:41 PM, rahul ranjan rahul.ranjan...@gmail.comwrote:

 @abhishek its wrong as arr1 is just a pointer o int and sizeof(arr1)
 will always be 4 bytes(size of a pointer) regardless of number of bytes
 allocated to it on heap


 On Tue, Jul 3, 2012 at 3:14 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 arr1 = (int *)malloc(sizeof(int) * ncols);// memory allocated for 1st
 row
 arr2 = (int **)malloc(sizeof(arr1) * nrows);

 I haven't tried it.So,please correct me if i am wrong


 On Mon, Jul 2, 2012 at 12:55 PM, Rishabh Agarwal rishabh...@gmail.comwrote:


 nrows: number of rows
 ncols: number of columns

 int **arra = (int **)malloc( sizeof(int*) * nrows );
 int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
 for( int a = 0; a  nrows; a ++ ) {
 arra[a] = ar + ncols * a;
 }

 now index of array i and j can be accessed as arra[i][j]



 On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:

 implement a 2d matrix using only 2 mallocs.

  --
 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/-/Pr2cEtta_LsJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe

2012-07-02 Thread Rishabh Agarwal

nrows: number of rows
ncols: number of columns

int **arra = (int **)malloc( sizeof(int*) * nrows );
int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
for( int a = 0; a  nrows; a ++ ) {
arra[a] = ar + ncols * a;
}

now index of array i and j can be accessed as arra[i][j]


On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:

 implement a 2d matrix using only 2 mallocs.


-- 
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/-/Pr2cEtta_LsJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Noida Interview Question

2012-05-01 Thread Ashish Goel
for second question think of the given string as some overlapping strings
with overlap length of length(pattern) -1.

now appy strstr/KMP in parallel to these substrings


Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, May 1, 2012 at 11:36 AM, vikas vikas.rastogi2...@gmail.com wrote:

 1) you cannot escape but exhaustive search, trying all possibilities

 2) basically you are asked to find string in stream, just try to do
 similar of Boyce-Moore , seems good for this problem.

 On Mar 30, 8:47 pm, Decipher ankurseth...@gmail.com wrote:
  This was asked from my friend in January for MTS profile.
 
  Q1) Given a matrix with letters in each square and you have to find words
  which are there in the dictionary (like Children's Crosswords). You have
  been given a function which outputs 1 if the given word is in the
  dictionary. The word could be bidirectionally horizontal, vertical
  or diagonal. Write an optimal algorithm for printing all such words.
 
  Q2) Given a very large string in which there is no kind of delimiter and
  you have been given function strstr() . Find a given string in the larger
  string using that function using minimum time and space.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Noida Interview Question

2012-04-29 Thread WgpShashank
Q2. better approach will be using KMP or Boyce Moore.


-- 
*Thanks
Shashank Mani Narayan
Computer Science  Engineering 
Birla Institute of Technology,Mesra 
**Founder Cracking The Code Lab  http://shashank7s.blogspot.com/;
FB Page 
http://www.facebook.com/LestCodehttp://www.facebook.com/pages/Cracking-The-Code/148241881919895
Google+ http://gplus.to/wgpshashank
Twitter https://twitter.com/wgpshashankhttps://twitter.com/#%21/wgpshashank
*

On Sunday, April 1, 2012 9:52:11 PM UTC+7, atul007 wrote:

 Q2 can be done using KMP algo or suffix tree

 On Sun, Apr 1, 2012 at 1:12 PM, Decipher ankurseth...@gmail.com wrote:

 Q1) Yes, as per my friend the only interface is that function. But how 
 will you traverse the matrix because if : BADCAT is one row then there are 
 two words BAD and CAT and you have to find both and it could be DAB and TAC 
 also ?

 Q2) What will be the complexity when state machine is used ?

 -- 
 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/-/RIgd-ITxYDEJ.

 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 at 
 http://groups.google.com/group/algogeeks?hl=en.




-- 
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/-/wt77Wy4S1qMJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Noida Interview Question

2012-04-01 Thread Decipher
Q1) Yes, as per my friend the only interface is that function. But how will 
you traverse the matrix because if : BADCAT is one row then there are two 
words BAD and CAT and you have to find both and it could be DAB and TAC 
also ?

Q2) What will be the complexity when state machine is used ?

-- 
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/-/RIgd-ITxYDEJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Noida Interview Question

2012-04-01 Thread atul anand
Q2 can be done using KMP algo or suffix tree

On Sun, Apr 1, 2012 at 1:12 PM, Decipher ankurseth...@gmail.com wrote:

 Q1) Yes, as per my friend the only interface is that function. But how
 will you traverse the matrix because if : BADCAT is one row then there are
 two words BAD and CAT and you have to find both and it could be DAB and TAC
 also ?

 Q2) What will be the complexity when state machine is used ?

 --
 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/-/RIgd-ITxYDEJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Noida Interview Question

2012-03-31 Thread Don
Q1) The only interface to the dictionary is this binary function? It
would be very helpful to know if there are words in the dictionary
with a given prefix. If the requirement is to find all words in the
matrix, as you stated, there is not a better option than to loop over
every string which can be formed from the matrix.

Q2) Use a state machine to match the string. If using strstr is a
requirement, I'll call it once, after I find the string, just to meet
that technicality.

Don

On Mar 30, 10:47 am, Decipher ankurseth...@gmail.com wrote:
 This was asked from my friend in January for MTS profile.

 Q1) Given a matrix with letters in each square and you have to find words
 which are there in the dictionary (like Children's Crosswords). You have
 been given a function which outputs 1 if the given word is in the
 dictionary. The word could be bidirectionally horizontal, vertical
 or diagonal. Write an optimal algorithm for printing all such words.

 Q2) Given a very large string in which there is no kind of delimiter and
 you have been given function strstr() . Find a given string in the larger
 string using that function using minimum time and space.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2012-01-18 Thread Arun Vishwanathan
@all : doesnt sudhir's solution seem to work??

@sudhir: can u explain yr logic?

On Wed, Sep 21, 2011 at 8:31 AM, annarao kataru kataruanna...@gmail.comwrote:

 can u explain the logic behind this

 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
 People often say that motivation doesn't last. Well, neither does bathing
- that's why we recommend it daily.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe

2011-10-15 Thread WgpShashank
@Rahul, We Are Working On It  Will Try to Eliminate the people if found 
they are doing same thing again

FYI:Google Docs is not Under Our Control, We Can't Implement our algorithm 
to filter out interview related thread to other group, if it would have been 
possible we just need to write small program to get rid of this ,as we just 
need to move  copy thread/files from one directory to other dir.,it will 
take some to filter out such thread.


Thanks
Shashank
CSE,BIT Mesra

-- 
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/-/8MaWYDpd4MQJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe

2011-10-14 Thread WgpShashank
@All Join Interview-Street Group For Detailed Discussion About Interview 
Process of Particular Company , if You Have particular question  wants to 
discuss here , put that directly , All Interview Related Task Now Shifted 
Interview-Street Group until Whole Thing is Done , You Can Search 
The Archive rather then creating new thread..




Thanks
Shashank
CSE, BIT Mesra

-- 
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/-/AZMotOCplFwJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe

2011-10-14 Thread rahul sharma
i dnt knw why still these posts are allowed in algogeeks

On Fri, Oct 14, 2011 at 7:37 PM, WgpShashank shashank7andr...@gmail.comwrote:

 @All Join Interview-Street Group For Detailed Discussion About Interview
 Process of Particular Company , if You Have particular question  wants to
 discuss here , put that directly , All Interview Related Task Now Shifted
 Interview-Street Group until Whole Thing is Done , You Can Search
 The Archive rather then creating new thread..




 Thanks
 Shashank
 CSE, BIT Mesra

 --
 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/-/AZMotOCplFwJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe question help

2011-10-02 Thread ravi ojha
in the first loop the value of k shuld vary from 0 to j-i.

On Oct 1, 7:26 am, rahul sharma rahul23111...@gmail.com wrote:
 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
 _

 #includestdio.h
 #includestdlib.h
 int main()
 {
     int N,M,i,j;
     printf(Enter value  of N \n);
     scanf(%d,N);
     fflush(stdin);
     printf(Enter value  of M \n);
     scanf(%d,M);
     fflush(stdin);
     printf(Enter value  of i \n);
     scanf(%d,i);
     fflush(stdin);
     printf(Enter value  of j \n);
     scanf(%d,j);
     fflush(stdin);
     int a=0,k;
     for( k=0;kj;k++)
     {
               a= a1;
               a=a|1;
     }
     for(k =0;ki;k++)
     {
           a=a1;
     }

     N = N (~a);
     printf(value of N is %d,N);
     for(k=0;ki;k++)
     M=M1;
     N=N|M;
     printf(value of N is %d,N);
     getchar();

 }

 isnt it give us wrong mask

 say i=2;

 j=6;

 it gives mask as(i.e ~a)

 0011

 but i think from 2 to 6 5 0's are neededplz tell the above prog is
 ok???or not???check by giving any input whose 7thy bit is set...thnx
 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe question help

2011-10-02 Thread rahul sharma
yeah u r ryt.

On Sun, Oct 2, 2011 at 4:20 PM, ravi ojha rbojha...@gmail.com wrote:

 in the first loop the value of k shuld vary from 0 to j-i.

 On Oct 1, 7:26 am, rahul sharma rahul23111...@gmail.com wrote:
  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
  _
 
  #includestdio.h
  #includestdlib.h
  int main()
  {
  int N,M,i,j;
  printf(Enter value  of N \n);
  scanf(%d,N);
  fflush(stdin);
  printf(Enter value  of M \n);
  scanf(%d,M);
  fflush(stdin);
  printf(Enter value  of i \n);
  scanf(%d,i);
  fflush(stdin);
  printf(Enter value  of j \n);
  scanf(%d,j);
  fflush(stdin);
  int a=0,k;
  for( k=0;kj;k++)
  {
a= a1;
a=a|1;
  }
  for(k =0;ki;k++)
  {
a=a1;
  }
 
  N = N (~a);
  printf(value of N is %d,N);
  for(k=0;ki;k++)
  M=M1;
  N=N|M;
  printf(value of N is %d,N);
  getchar();
 
  }
 
  isnt it give us wrong mask
 
  say i=2;
 
  j=6;
 
  it gives mask as(i.e ~a)
 
  0011
 
  but i think from 2 to 6 5 0's are neededplz tell the above prog is
  ok???or not???check by giving any input whose 7thy bit is set...thnx
  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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe question help

2011-10-02 Thread rahul sharma
can u tell in this we have to set i and j also or only between elements
say if i=2 and j=6
then
whether we should set bit no 2,3,4,5,6,
or 3,4,5

acc. to me its 2,3,4,5,6,
and ur logic also give that answer
plz tell??

On Sun, Oct 2, 2011 at 4:38 PM, rahul sharma rahul23111...@gmail.comwrote:

 yeah u r ryt.


 On Sun, Oct 2, 2011 at 4:20 PM, ravi ojha rbojha...@gmail.com wrote:

 in the first loop the value of k shuld vary from 0 to j-i.

 On Oct 1, 7:26 am, rahul sharma rahul23111...@gmail.com wrote:
  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
  _
 
  #includestdio.h
  #includestdlib.h
  int main()
  {
  int N,M,i,j;
  printf(Enter value  of N \n);
  scanf(%d,N);
  fflush(stdin);
  printf(Enter value  of M \n);
  scanf(%d,M);
  fflush(stdin);
  printf(Enter value  of i \n);
  scanf(%d,i);
  fflush(stdin);
  printf(Enter value  of j \n);
  scanf(%d,j);
  fflush(stdin);
  int a=0,k;
  for( k=0;kj;k++)
  {
a= a1;
a=a|1;
  }
  for(k =0;ki;k++)
  {
a=a1;
  }
 
  N = N (~a);
  printf(value of N is %d,N);
  for(k=0;ki;k++)
  M=M1;
  N=N|M;
  printf(value of N is %d,N);
  getchar();
 
  }
 
  isnt it give us wrong mask
 
  say i=2;
 
  j=6;
 
  it gives mask as(i.e ~a)
 
  0011
 
  but i think from 2 to 6 5 0's are neededplz tell the above prog is
  ok???or not???check by giving any input whose 7thy bit is set...thnx
  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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe final interview question : small change

2011-09-24 Thread algo geek
Can you please explain. I dont know about design patterns. Also please share
some good book for design patterns.
thanks

On Fri, Sep 23, 2011 at 4:07 PM, Prem Krishna Chettri hprem...@gmail.comwrote:

 This is Simple query related to Factory Design Pattern... Have a look at
 the Auto Registration of Factory Design pattern..


 :)
 Prem


 On Fri, Sep 23, 2011 at 3:02 PM, algo geek geeka...@gmail.com wrote:

 You have a library provided by the vendor. All you have is header files
 and library files.
 Library contains the class Shape and there is whole hierarchy tree (i mean
 classes which derive from this base class).
 Now you want to add some function getArea (not originally present in the
 class or any of its derived class) in the class Shape , you dont have the
 source code.

 Using this library, you have written a lot of code. Now you have to make
 some changes so that, any object of Shape class (or its derived class) will
 be able to call this function.
 With your strategy, you should be able to override the definition of this
 function in the derived class.

 I think it is related to design patterns, not sure.
 I gave the solution that : we will use MyShape , and use composition. i.e.
 will create the object of Shape class inside this NewShape class and
 interface can be made. Internally, we can call the functions of Shape
 object. That will work fine. But we have to do this for the whole design
 hierarchy. Secondly, if there is some changes by the vendor in future in the
 library, i have to change my new design tree.
 e.g.
 class Shape {
public : void draw();
   void clear();
 }
 class Circle : public Shape{
public : void draw();
   void clear();
 }
 class Rectangle: public Shape{
public : void draw();
   void clear();
 }


 class NewShape{
 private Shape * obj;
public : void draw(){ obj-draw(); }
   void clear() { obj-clear(); }
   int getArear(){
  //implementtation of getArea function
   }
 }

 class NewCircle : NewShape{
public : void draw(){ (Circle*)obj-draw(); }
   void clear() { (Circle*)obj-clear(); }
   int getArear(){
  //implementtation of getArea function specific to
 circle
   }
 }
 class NewRectangle : NewShape{
public : void draw(){ (Rectangle*)obj-draw(); }
   void clear() { (Rctangle*)obj-clear(); }
   int getArear(){
  //implementtation of getArea function
   }
 }

 I know this solution is not good.. please provide a better approach for
 this.
 Please let me knw if anything is not clear.




 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe final interview question : small change

2011-09-23 Thread algo geek
You have a library provided by the vendor. All you have is header files and
library files.
Library contains the class Shape and there is whole hierarchy tree (i mean
classes which derive from this base class).
Now you want to add some function getArea (not originally present in the
class or any of its derived class) in the class Shape , you dont have the
source code.

Using this library, you have written a lot of code. Now you have to make
some changes so that, any object of Shape class (or its derived class) will
be able to call this function.
With your strategy, you should be able to override the definition of this
function in the derived class.

I think it is related to design patterns, not sure.
I gave the solution that : we will use MyShape , and use composition. i.e.
will create the object of Shape class inside this NewShape class and
interface can be made. Internally, we can call the functions of Shape
object. That will work fine. But we have to do this for the whole design
hierarchy. Secondly, if there is some changes by the vendor in future in the
library, i have to change my new design tree.
e.g.
class Shape {
   public : void draw();
  void clear();
}
class Circle : public Shape{
   public : void draw();
  void clear();
}
class Rectangle: public Shape{
   public : void draw();
  void clear();
}


class NewShape{
private Shape * obj;
   public : void draw(){ obj-draw(); }
  void clear() { obj-clear(); }
  int getArear(){
 //implementtation of getArea function
  }
}

class NewCircle : NewShape{
   public : void draw(){ (Circle*)obj-draw(); }
  void clear() { (Circle*)obj-clear(); }
  int getArear(){
 //implementtation of getArea function specific to
circle
  }
}
class NewRectangle : NewShape{
   public : void draw(){ (Rectangle*)obj-draw(); }
  void clear() { (Rctangle*)obj-clear(); }
  int getArear(){
 //implementtation of getArea function
  }
}

I know this solution is not good.. please provide a better approach for
this.
Please let me knw if anything is not clear.




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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe final interview question : small change

2011-09-23 Thread Prem Krishna Chettri
This is Simple query related to Factory Design Pattern... Have a look at the
Auto Registration of Factory Design pattern..


:)
Prem


On Fri, Sep 23, 2011 at 3:02 PM, algo geek geeka...@gmail.com wrote:

 You have a library provided by the vendor. All you have is header files and
 library files.
 Library contains the class Shape and there is whole hierarchy tree (i mean
 classes which derive from this base class).
 Now you want to add some function getArea (not originally present in the
 class or any of its derived class) in the class Shape , you dont have the
 source code.

 Using this library, you have written a lot of code. Now you have to make
 some changes so that, any object of Shape class (or its derived class) will
 be able to call this function.
 With your strategy, you should be able to override the definition of this
 function in the derived class.

 I think it is related to design patterns, not sure.
 I gave the solution that : we will use MyShape , and use composition. i.e.
 will create the object of Shape class inside this NewShape class and
 interface can be made. Internally, we can call the functions of Shape
 object. That will work fine. But we have to do this for the whole design
 hierarchy. Secondly, if there is some changes by the vendor in future in the
 library, i have to change my new design tree.
 e.g.
 class Shape {
public : void draw();
   void clear();
 }
 class Circle : public Shape{
public : void draw();
   void clear();
 }
 class Rectangle: public Shape{
public : void draw();
   void clear();
 }


 class NewShape{
 private Shape * obj;
public : void draw(){ obj-draw(); }
   void clear() { obj-clear(); }
   int getArear(){
  //implementtation of getArea function
   }
 }

 class NewCircle : NewShape{
public : void draw(){ (Circle*)obj-draw(); }
   void clear() { (Circle*)obj-clear(); }
   int getArear(){
  //implementtation of getArea function specific to
 circle
   }
 }
 class NewRectangle : NewShape{
public : void draw(){ (Rectangle*)obj-draw(); }
   void clear() { (Rctangle*)obj-clear(); }
   int getArear(){
  //implementtation of getArea function
   }
 }

 I know this solution is not good.. please provide a better approach for
 this.
 Please let me knw if anything is not clear.




 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-09-21 Thread annarao kataru
can u explain the logic behind this

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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-09-17 Thread priyanka raju
*

*
*#include fstream
#include iostream
using namespace std;
bool flag=false;
void check(int i)
{
int sum=0;
char n[5];
itoa(i,n,10);
for(int j=0;j5  n[j] != '\0';j++)
{
char p = n[j];
sum += atoi(p);
}
if(sum==3 || sum==6 || sum==9)
flag = true;
else if(sum9)
check(sum);
}

void main()
{
int i;
coutEnter the number : ;
cini;
check(i);
if(flag == true)
couti is divisible by '3'endl;
else
couti is not divisible by '3'endl;
}*

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe written test

2011-09-08 Thread Amit Gupta
Written test of adobe had 3 sections -
Quant and Analytical section - 45 questions(30 + 15) 45 mins
2 coding papers - 1 hr each , 10 ques each
1st coding paper had general MCQ  (test ur c skills type )
2nd coding paper had ques for writing algos, codes and few OS
questions.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe written test

2011-09-08 Thread pavan kumar
Thnx Amit...Can any one post some sample ques so that it vl be very useful
??

On Thu, Sep 8, 2011 at 11:41 AM, Amit Gupta amit070...@gmail.com wrote:

 Written test of adobe had 3 sections -
 Quant and Analytical section - 45 questions(30 + 15) 45 mins
 2 coding papers - 1 hr each , 10 ques each
 1st coding paper had general MCQ  (test ur c skills type )
 2nd coding paper had ques for writing algos, codes and few OS
 questions.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 



Regards:
---
K Pavan Kumar
Computer Science  Engg.
2nd Mtech, IIT Madras.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-29 Thread vikas
oops

On Aug 28, 7:09 pm, Decipher ankurseth...@gmail.com wrote:
 @vikas - As i said earlier think in 3D . The correct answer is (sqrt(3) -
 1)R/(sqrt(3) + 1) = r

 Using 3D coordinate geometry if (R,R,R) and (r,r,r) are the coordinates of
 center of large and small sphere . Then , make distance formula for centers
 of sphere in 3D = (R+r)

 *Now don't ask distance formula in 3D*

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-28 Thread Decipher
@vikas - As i said earlier think in 3D . The correct answer is (sqrt(3) - 
1)R/(sqrt(3) + 1) = r 

Using 3D coordinate geometry if (R,R,R) and (r,r,r) are the coordinates of 
center of large and small sphere . Then , make distance formula for centers 
of sphere in 3D = (R+r)

*Now don't ask distance formula in 3D*

-- 
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/-/fbst4TY4e2EJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[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 wrote:
  5th qs

  r = R(3-2sqrt(2))

  On Aug 25, 1:56 pm, vikas vikas.rastogi2...@gmail.com wrote:
   @ All,
   1.   build a interval tree using startpoints as the key
   2.   augment this tree such that each interval contains the number of
   ppl arrived, in this case 1.
   3.   use this tree and traverse , use this check, if start/end of tree
   node is inbetween the interval you are searching, person was there.

   sample code
   getMaxNumPpl(node *root, int start, int end)
   {
      int n = 0;
      if(root == NULL) return 0;
      if(CHECK(root-start, root-end, start, end)){
      n++;
      }
      n += getMaxNumPpl(root-left, start, end);
      n += getMaxNumPpl(root-right, start, end);
     return n;

   }

   On Aug 24, 8:42 pm, rakesh kumar rockey.rav...@gmail.com wrote:

Hi

Anybody has answer for sphere problem...could you please proivde

On Wed, Aug 24, 2011 at 9:10 PM, rakesh kumar rockey.rav...@gmail.com
  wrote:

 Hi All,
 for  checkouts problem how about finding the median for all the
  times

 8-00 8-15 830
 sort the second list
 8-30 900 920
 if we take the mediun of  whole list then it will be 8-30 where max
  no of
 people will be present

 Will it work..

 Any body has any idea??

 On Wed, Aug 24, 2011 at 12:58 AM, DK divyekap...@gmail.com wrote:

 Well, strictly speaking, you don't need any complex data structures:

 *1. Create an array of entities*
 eg. Person data[100];
 where
 struct Person {
  // Person data
 };

 *2. Create an array of timestamps:*
 Event time[200]; // Note: double the size of the Person data array.
  One
 for start and one for finish time.
 where
 struct Event {
    Person *p; // To maintain a reference to the original person data
    int time; // say in seconds
    bool finish; // default: false
 };

 *3. Sort the time array based on the time value*

 *4. Now, simply maintain a counter*
 int num_people = 0;
 int max = 0;
 for each event in time:
    if(event.finish == true) --num_people;
    else ++num_people;
    if(num_people  max) max = num_people;

 Time Complexity: O(N log N)
 Space Complexity: O(N)

 --
 DK

http://twitter.com/divyekapoor
http://www.divye.in
http://gplus.to/divyekapoor

 --
 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/-/XrR_OjPOVagJ.

 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 at
http://groups.google.com/group/algogeeks?hl=en.

  --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-25 Thread vikas
@ All,
1.   build a interval tree using startpoints as the key
2.   augment this tree such that each interval contains the number of
ppl arrived, in this case 1.
3.   use this tree and traverse , use this check, if start/end of tree
node is inbetween the interval you are searching, person was there.

sample code
getMaxNumPpl(node *root, int start, int end)
{
   int n = 0;
   if(root == NULL) return 0;
   if(CHECK(root-start, root-end, start, end)){
   n++;
   }
   n += getMaxNumPpl(root-left, start, end);
   n += getMaxNumPpl(root-right, start, end);
  return n;
}


On Aug 24, 8:42 pm, rakesh kumar rockey.rav...@gmail.com wrote:
 Hi

 Anybody has answer for sphere problem...could you please proivde

 On Wed, Aug 24, 2011 at 9:10 PM, rakesh kumar rockey.rav...@gmail.comwrote:







  Hi All,
  for  checkouts problem how about finding the median for all the times

  8-00 8-15 830
  sort the second list
  8-30 900 920
  if we take the mediun of  whole list then it will be 8-30 where max no of
  people will be present

  Will it work..

  Any body has any idea??

  On Wed, Aug 24, 2011 at 12:58 AM, DK divyekap...@gmail.com wrote:

  Well, strictly speaking, you don't need any complex data structures:

  *1. Create an array of entities*
  eg. Person data[100];
  where
  struct Person {
   // Person data
  };

  *2. Create an array of timestamps:*
  Event time[200]; // Note: double the size of the Person data array. One
  for start and one for finish time.
  where
  struct Event {
     Person *p; // To maintain a reference to the original person data
     int time; // say in seconds
     bool finish; // default: false
  };

  *3. Sort the time array based on the time value*

  *4. Now, simply maintain a counter*
  int num_people = 0;
  int max = 0;
  for each event in time:
     if(event.finish == true) --num_people;
     else ++num_people;
     if(num_people  max) max = num_people;

  Time Complexity: O(N log N)
  Space Complexity: O(N)

  --
  DK

 http://twitter.com/divyekapoor
 http://www.divye.in
 http://gplus.to/divyekapoor

  --
  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/-/XrR_OjPOVagJ.

  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 at
 http://groups.google.com/group/algogeeks?hl=en.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-25 Thread vikas
5th qs

r = R(3-2sqrt(2))

On Aug 25, 1:56 pm, vikas vikas.rastogi2...@gmail.com wrote:
 @ All,
 1.   build a interval tree using startpoints as the key
 2.   augment this tree such that each interval contains the number of
 ppl arrived, in this case 1.
 3.   use this tree and traverse , use this check, if start/end of tree
 node is inbetween the interval you are searching, person was there.

 sample code
 getMaxNumPpl(node *root, int start, int end)
 {
    int n = 0;
    if(root == NULL) return 0;
    if(CHECK(root-start, root-end, start, end)){
    n++;
    }
    n += getMaxNumPpl(root-left, start, end);
    n += getMaxNumPpl(root-right, start, end);
   return n;

 }

 On Aug 24, 8:42 pm, rakesh kumar rockey.rav...@gmail.com wrote:







  Hi

  Anybody has answer for sphere problem...could you please proivde

  On Wed, Aug 24, 2011 at 9:10 PM, rakesh kumar 
  rockey.rav...@gmail.comwrote:

   Hi All,
   for  checkouts problem how about finding the median for all the times

   8-00 8-15 830
   sort the second list
   8-30 900 920
   if we take the mediun of  whole list then it will be 8-30 where max no of
   people will be present

   Will it work..

   Any body has any idea??

   On Wed, Aug 24, 2011 at 12:58 AM, DK divyekap...@gmail.com wrote:

   Well, strictly speaking, you don't need any complex data structures:

   *1. Create an array of entities*
   eg. Person data[100];
   where
   struct Person {
    // Person data
   };

   *2. Create an array of timestamps:*
   Event time[200]; // Note: double the size of the Person data array. One
   for start and one for finish time.
   where
   struct Event {
      Person *p; // To maintain a reference to the original person data
      int time; // say in seconds
      bool finish; // default: false
   };

   *3. Sort the time array based on the time value*

   *4. Now, simply maintain a counter*
   int num_people = 0;
   int max = 0;
   for each event in time:
      if(event.finish == true) --num_people;
      else ++num_people;
      if(num_people  max) max = num_people;

   Time Complexity: O(N log N)
   Space Complexity: O(N)

   --
   DK

  http://twitter.com/divyekapoor
  http://www.divye.in
  http://gplus.to/divyekapoor

   --
   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/-/XrR_OjPOVagJ.

   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 at
  http://groups.google.com/group/algogeeks?hl=en.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-25 Thread WgpShashank
@Diye True :)


Shashank 
CSE,BIT Mesra

-- 
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/-/O_KMuq1YK_0J.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-25 Thread rakesh kumar
Could you explain the solution for shere problem

On Thu, Aug 25, 2011 at 3:49 PM, vikas vikas.rastogi2...@gmail.com wrote:

 5th qs

 r = R(3-2sqrt(2))

 On Aug 25, 1:56 pm, vikas vikas.rastogi2...@gmail.com wrote:
  @ All,
  1.   build a interval tree using startpoints as the key
  2.   augment this tree such that each interval contains the number of
  ppl arrived, in this case 1.
  3.   use this tree and traverse , use this check, if start/end of tree
  node is inbetween the interval you are searching, person was there.
 
  sample code
  getMaxNumPpl(node *root, int start, int end)
  {
 int n = 0;
 if(root == NULL) return 0;
 if(CHECK(root-start, root-end, start, end)){
 n++;
 }
 n += getMaxNumPpl(root-left, start, end);
 n += getMaxNumPpl(root-right, start, end);
return n;
 
  }
 
  On Aug 24, 8:42 pm, rakesh kumar rockey.rav...@gmail.com wrote:
 
 
 
 
 
 
 
   Hi
 
   Anybody has answer for sphere problem...could you please proivde
 
   On Wed, Aug 24, 2011 at 9:10 PM, rakesh kumar rockey.rav...@gmail.com
 wrote:
 
Hi All,
for  checkouts problem how about finding the median for all the
 times
 
8-00 8-15 830
sort the second list
8-30 900 920
if we take the mediun of  whole list then it will be 8-30 where max
 no of
people will be present
 
Will it work..
 
Any body has any idea??
 
On Wed, Aug 24, 2011 at 12:58 AM, DK divyekap...@gmail.com wrote:
 
Well, strictly speaking, you don't need any complex data structures:
 
*1. Create an array of entities*
eg. Person data[100];
where
struct Person {
 // Person data
};
 
*2. Create an array of timestamps:*
Event time[200]; // Note: double the size of the Person data array.
 One
for start and one for finish time.
where
struct Event {
   Person *p; // To maintain a reference to the original person data
   int time; // say in seconds
   bool finish; // default: false
};
 
*3. Sort the time array based on the time value*
 
*4. Now, simply maintain a counter*
int num_people = 0;
int max = 0;
for each event in time:
   if(event.finish == true) --num_people;
   else ++num_people;
   if(num_people  max) max = num_people;
 
Time Complexity: O(N log N)
Space Complexity: O(N)
 
--
DK
 
   http://twitter.com/divyekapoor
   http://www.divye.in
   http://gplus.to/divyekapoor
 
--
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/-/XrR_OjPOVagJ.
 
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 at
   http://groups.google.com/group/algogeeks?hl=en.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-24 Thread rakesh kumar
Hi All,
for  checkouts problem how about finding the median for all the times

8-00 8-15 830
sort the second list
8-30 900 920
if we take the mediun of  whole list then it will be 8-30 where max no of
people will be present

Will it work..

Any body has any idea??




On Wed, Aug 24, 2011 at 12:58 AM, DK divyekap...@gmail.com wrote:

 Well, strictly speaking, you don't need any complex data structures:

 *1. Create an array of entities*
 eg. Person data[100];
 where
 struct Person {
  // Person data
 };

 *2. Create an array of timestamps:*
 Event time[200]; // Note: double the size of the Person data array. One for
 start and one for finish time.
 where
 struct Event {
Person *p; // To maintain a reference to the original person data
int time; // say in seconds
bool finish; // default: false
 };

 *3. Sort the time array based on the time value*

 *4. Now, simply maintain a counter*
 int num_people = 0;
 int max = 0;
 for each event in time:
if(event.finish == true) --num_people;
else ++num_people;
if(num_people  max) max = num_people;

 Time Complexity: O(N log N)
 Space Complexity: O(N)

 --
 DK

 http://twitter.com/divyekapoor
 http://www.divye.in
 http://gplus.to/divyekapoor

 --
 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/-/XrR_OjPOVagJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-24 Thread rakesh kumar
Hi

Anybody has answer for sphere problem...could you please proivde

On Wed, Aug 24, 2011 at 9:10 PM, rakesh kumar rockey.rav...@gmail.comwrote:

 Hi All,
 for  checkouts problem how about finding the median for all the times

 8-00 8-15 830
 sort the second list
 8-30 900 920
 if we take the mediun of  whole list then it will be 8-30 where max no of
 people will be present

 Will it work..

 Any body has any idea??




 On Wed, Aug 24, 2011 at 12:58 AM, DK divyekap...@gmail.com wrote:

 Well, strictly speaking, you don't need any complex data structures:

 *1. Create an array of entities*
 eg. Person data[100];
 where
 struct Person {
  // Person data
 };

 *2. Create an array of timestamps:*
 Event time[200]; // Note: double the size of the Person data array. One
 for start and one for finish time.
 where
 struct Event {
Person *p; // To maintain a reference to the original person data
int time; // say in seconds
bool finish; // default: false
 };

 *3. Sort the time array based on the time value*

 *4. Now, simply maintain a counter*
 int num_people = 0;
 int max = 0;
 for each event in time:
if(event.finish == true) --num_people;
else ++num_people;
if(num_people  max) max = num_people;

 Time Complexity: O(N log N)
 Space Complexity: O(N)

 --
 DK

 http://twitter.com/divyekapoor
 http://www.divye.in
 http://gplus.to/divyekapoor

 --
 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/-/XrR_OjPOVagJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-23 Thread Abhishek Yadav
@vikas: can you please put some light over interval graph to solve this
problem or provide some useful links??

On Mon, Aug 22, 2011 at 6:47 PM, Decipher ankurseth...@gmail.com wrote:

 @vikas - Can u post ur answer using segment trees ??

 --
 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/-/ssVg6dOuXiUJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-23 Thread DK
Well, strictly speaking, you don't need any complex data structures:

*1. Create an array of entities*
eg. Person data[100];
where 
struct Person {
 // Person data
};

*2. Create an array of timestamps:*
Event time[200]; // Note: double the size of the Person data array. One for 
start and one for finish time.
where
struct Event {
   Person *p; // To maintain a reference to the original person data
   int time; // say in seconds
   bool finish; // default: false
};

*3. Sort the time array based on the time value*

*4. Now, simply maintain a counter*
int num_people = 0;
int max = 0;
for each event in time:
   if(event.finish == true) --num_people;
   else ++num_people;
   if(num_people  max) max = num_people;

Time Complexity: O(N log N)
Space Complexity: O(N)

--
DK

http://twitter.com/divyekapoor
http://www.divye.in
http://gplus.to/divyekapoor

-- 
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/-/XrR_OjPOVagJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-22 Thread vikas
using interval tree/segment tree will solve this in straightforward
fashion

On Aug 22, 12:41 pm, Jagannath Prasad Das jpdasi...@gmail.com wrote:
 for the stick prob is the stick length required?

 On Mon, Aug 22, 2011 at 12:48 PM, Jagannath Prasad Das
 jpdasi...@gmail.comwrote:







  i think find max and min of all time-stamps respectively

  On Mon, Aug 22, 2011 at 12:44 PM, saurabh agrawal 
  saurabh...@gmail.comwrote:

  How did u solved :

  3) There is a list containing the checkin and checkout time of every
  person in a party . The checkin time is in ascending order while the
  checkout is random .

  Eg:

                         Check_in                Check_out

  Person 1             8.00                          9.00

  Person 2             8.15                          8.30

  Person 3             8.30                          9.20

  On Mon, Aug 22, 2011 at 9:14 AM, Decipher ankurseth...@gmail.com wrote:

  Hi,

  This is my Adobe interview experience for freshers :

   *Written Test:*

  Engineering               – 45 Minutes - Data Structures, Algorithms,
  Operating Systems

  C/C++                      – 45 Minutes - C/C++ Fundamentals  Coding***
  *

  Aptitude                    – 45 Minutes – Quantitative  Analytical

  * *

  *On clearing the Test, 3 Technical Interviews + HR discussion on the
  same day.*

  *
  *

  *Interview 1: *

  1) Insert an element in a linked list at the end , given the *start *
  pointer.

  2) Write a function to Swap pointers .

  3) There is a list containing the checkin and checkout time of every
  person in a party . The checkin time is in ascending order while the
  checkout is random .

  Eg:

                         Check_in                Check_out

  Person 1             8.00                          9.00

  Person 2             8.15                          8.30

  Person 3             8.30                          9.20

  and so on ...
  Now , give an optimized solution to find at what time the maximum number
  of people will be in the party . My solution - O(nlogn) time and O(n) 
  space
  . He gave another O(nlogn) time and O(n) space solution .

  and some other questions that I can't recal ..

  *Interview 2:*
  1) Base class contains 2 functions and Derived class (with Private
  Inheritance from Base) also contains 2 functions (same name as those in 
  Base
  cass), then he asked me the effect by changing the Inheritance type and
   making different functions virtual like - virtual func in Base then in
  Derived and then both .

  2) Same question appended- A derived class *A* derived from Derived and
  Base , now

  A a = new A;
  Base *b =  a;
  Derived *d = a;

  b = d;

  and b = (Base *) d;

  then which functions can I call ?

  3) Convert a tree into its mirror without using extra memory - O(1) space
  .

  4) If an array is rotated a number of unknown times , then how to find an
  element in O(log n)

  5) There are 3 sticks placed at right angles to each other and a sphere
  is placed between the sticks . Now another sphere is placed in the gap
  between the sticks and Larger sphere . Find the radius of smaller sphere 
  in
  terms of radius of larger sphere .

  *This is as far I can remember so please don't ask any questions
  regarding it .*

   --
  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/-/K0ws20ht-pkJ.
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

   --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-22 Thread Sachin Jain
If an array is rotated a number of unknown times , then how to find an
element in O(log n)

For the above question, is the array already sorted???

On Mon, Aug 22, 2011 at 2:50 PM, vikas vikas.rastogi2...@gmail.com wrote:

 using interval tree/segment tree will solve this in straightforward
 fashion

 On Aug 22, 12:41 pm, Jagannath Prasad Das jpdasi...@gmail.com wrote:
  for the stick prob is the stick length required?
 
  On Mon, Aug 22, 2011 at 12:48 PM, Jagannath Prasad Das
  jpdasi...@gmail.comwrote:
 
 
 
 
 
 
 
   i think find max and min of all time-stamps respectively
 
   On Mon, Aug 22, 2011 at 12:44 PM, saurabh agrawal 
 saurabh...@gmail.comwrote:
 
   How did u solved :
 
   3) There is a list containing the checkin and checkout time of every
   person in a party . The checkin time is in ascending order while the
   checkout is random .
 
   Eg:
 
  Check_inCheck_out
 
   Person 1 8.00  9.00
 
   Person 2 8.15  8.30
 
   Person 3 8.30  9.20
 
   On Mon, Aug 22, 2011 at 9:14 AM, Decipher ankurseth...@gmail.com
 wrote:
 
   Hi,
 
   This is my Adobe interview experience for freshers :
 
*Written Test:*
 
   Engineering   – 45 Minutes - Data Structures, Algorithms,
   Operating Systems
 
   C/C++  – 45 Minutes - C/C++ Fundamentals 
 Coding***
   *
 
   Aptitude– 45 Minutes – Quantitative  Analytical
 
   * *
 
   *On clearing the Test, 3 Technical Interviews + HR discussion on the
   same day.*
 
   *
   *
 
   *Interview 1: *
 
   1) Insert an element in a linked list at the end , given the *start *
   pointer.
 
   2) Write a function to Swap pointers .
 
   3) There is a list containing the checkin and checkout time of every
   person in a party . The checkin time is in ascending order while the
   checkout is random .
 
   Eg:
 
  Check_inCheck_out
 
   Person 1 8.00  9.00
 
   Person 2 8.15  8.30
 
   Person 3 8.30  9.20
 
   and so on ...
   Now , give an optimized solution to find at what time the maximum
 number
   of people will be in the party . My solution - O(nlogn) time and O(n)
 space
   . He gave another O(nlogn) time and O(n) space solution .
 
   and some other questions that I can't recal ..
 
   *Interview 2:*
   1) Base class contains 2 functions and Derived class (with Private
   Inheritance from Base) also contains 2 functions (same name as those
 in Base
   cass), then he asked me the effect by changing the Inheritance type
 and
making different functions virtual like - virtual func in Base then
 in
   Derived and then both .
 
   2) Same question appended- A derived class *A* derived from Derived
 and
   Base , now
 
   A a = new A;
   Base *b =  a;
   Derived *d = a;
 
   b = d;
 
   and b = (Base *) d;
 
   then which functions can I call ?
 
   3) Convert a tree into its mirror without using extra memory - O(1)
 space
   .
 
   4) If an array is rotated a number of unknown times , then how to
 find an
   element in O(log n)
 
   5) There are 3 sticks placed at right angles to each other and a
 sphere
   is placed between the sticks . Now another sphere is placed in the
 gap
   between the sticks and Larger sphere . Find the radius of smaller
 sphere in
   terms of radius of larger sphere .
 
   *This is as far I can remember so please don't ask any questions
   regarding it .*
 
--
   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/-/K0ws20ht-pkJ.
   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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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] Re: Adobe Interview - 20/08/2011

2011-08-22 Thread Decipher
Yup array is sorted first then rotated !!!

-- 
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/-/1CYpZg2TLzYJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-08-22 Thread Decipher
@vikas - Can u post ur answer using segment trees ??

-- 
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/-/ssVg6dOuXiUJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-20 Thread Ravi Shankar
oops sorry...it will be (root3-1)R/(root3+1)
...the above answer will be for 2d..
Ravi Shankar,
R  D,HCL Comnet,
Noida,
Ph:995369



On Sat, Aug 20, 2011 at 4:04 PM, Ravi Shankar ravi.iiit...@gmail.comwrote:

 I guess the correct answer is (root2-1)R/(root2+1)


 ?


 Ravi Shankar,
 R  D, HCL Comnet,
 Noida,
 Ph:995369




 On Sat, Aug 20, 2011 at 4:10 AM, Arihant lucky0...@gmail.com wrote:

 I could not visualize the situation, could please elaborate on the
 positioning of the axis and the spheres?

 You haven't told whether they are touching each other or not ?

 --
 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/-/hC_-59e9SmsJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread Greeshma
is it (root 2 - 1) * R ?

-- 
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/-/zwlqxDgQXFgJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread Abhishek Gupta
(root2-1)R/root2+1??

On Fri, Aug 19, 2011 at 8:03 PM, Greeshma greeshma.0...@gmail.com wrote:

 is it (root 2 - 1) * R ?

 --
 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/-/zwlqxDgQXFgJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread priya ramesh
(root(2)-1)*r???

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread Greeshma
ya tats d ans i got..

-- 
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/-/VRqgtJewfHsJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread Decipher
I don't know the answer since my friend who had given the interview was not 
able to answer the questions . But remember its a SPHERE so think in 3-D 
rather then 2-D and also please give the logic behind your answer .

-- 
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/-/bXosLfEakFkJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread Arihant
I could not visualize the situation, could please elaborate on the 
positioning of the axis and the spheres?

You haven't told whether they are touching each other or not ? 

-- 
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/-/hC_-59e9SmsJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2011-08-06 Thread Nikhil Gupta
@sumit, these numbers containing all ones are not in binary representation.
They are in decimal system.

On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com wrote:

 yes u r wrong..
 1 is nt divisible by 23


 On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:

 This looks quite simple.
 Every number ending in 3 follows a pattern.eg-
 3 - 111
 13 - 11
 23 - 1 etc
 we can find the reauired no. by :
 suppose input no. is 33
 In every case leave the no at 1's place(least significant) i.e. 3, In
 33 you will be left with 3(after removal of 3 at first place).
 Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 = 12 i.e  ).
 for 103 it is 3*(10+1) = 33 1's.

 Correct if I am wrong.


 On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
  ADOBE asks the very basic C/C++ questions
 
  one of their toughest however was :
 
  every number ending in 3 has a multiple of the form 111...111
 
  e.g 3 has 111
   13 has 11
  so on..
 
  find the algo for finding the number for an input number ending in 3.
 
  On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
 
 
 
 
 
 
   hey, guys adobe is visiting our campus. So those who know questions
   that adobe asked in written or interview, please post here as it will
   be of great help (as adobe has visited some colleges already).
   Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, India

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2011-08-06 Thread sagar pareek
please anyone of you post more question asked by adobe this yr...
please

On Sat, Aug 6, 2011 at 12:24 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 @sumit, these numbers containing all ones are not in binary representation.
 They are in decimal system.


 On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.comwrote:

 yes u r wrong..
 1 is nt divisible by 23


 On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:

 This looks quite simple.
 Every number ending in 3 follows a pattern.eg-
 3 - 111
 13 - 11
 23 - 1 etc
 we can find the reauired no. by :
 suppose input no. is 33
 In every case leave the no at 1's place(least significant) i.e. 3, In
 33 you will be left with 3(after removal of 3 at first place).
 Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 = 12 i.e  ).
 for 103 it is 3*(10+1) = 33 1's.

 Correct if I am wrong.


 On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
  ADOBE asks the very basic C/C++ questions
 
  one of their toughest however was :
 
  every number ending in 3 has a multiple of the form 111...111
 
  e.g 3 has 111
   13 has 11
  so on..
 
  find the algo for finding the number for an input number ending in 3.
 
  On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
 
 
 
 
 
 
   hey, guys adobe is visiting our campus. So those who know questions
   that adobe asked in written or interview, please post here as it will
   be of great help (as adobe has visited some colleges already).
   Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT 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 this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2011-08-06 Thread Nitin Nizhawan
http://trickofmind.com/?p=1080
i think this will help, we need to find Carmichael number or somthing
related to ETF for the input number.

On Sat, Aug 6, 2011 at 12:24 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 @sumit, these numbers containing all ones are not in binary representation.
 They are in decimal system.


 On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.comwrote:

 yes u r wrong..
 1 is nt divisible by 23


 On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:

 This looks quite simple.
 Every number ending in 3 follows a pattern.eg-
 3 - 111
 13 - 11
 23 - 1 etc
 we can find the reauired no. by :
 suppose input no. is 33
 In every case leave the no at 1's place(least significant) i.e. 3, In
 33 you will be left with 3(after removal of 3 at first place).
 Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 = 12 i.e  ).
 for 103 it is 3*(10+1) = 33 1's.

 Correct if I am wrong.


 On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
  ADOBE asks the very basic C/C++ questions
 
  one of their toughest however was :
 
  every number ending in 3 has a multiple of the form 111...111
 
  e.g 3 has 111
   13 has 11
  so on..
 
  find the algo for finding the number for an input number ending in 3.
 
  On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
 
 
 
 
 
 
   hey, guys adobe is visiting our campus. So those who know questions
   that adobe asked in written or interview, please post here as it will
   be of great help (as adobe has visited some colleges already).
   Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

  --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: Re: [algogeeks] Re: adobe

2011-08-06 Thread vaibhavmittal11
Mukul, in first approach instead of sending the string again and again u  
can use the formula

(a*b)%m = ((a%m)*(b%m))%m
this way u can do sumthin like dis

int count = 0, a = 1;
while(a != 0) {
count++;
a = ((a*10)%n + 1) %n;
}

n later output a string consisting of count one's..

Regards
VM
3rd Year, Computer Engineering,
Netaji Subhas Institute of Technology.

On , Mukul Gupta mukul.gupta...@gmail.com wrote:

Manee, Nice Question.
I have thought of two algorithms. I wanted to know how one judges them.  
Both have similar time complexity but the 2nd one is slightly complex and  
much more logical.


1. Keeping on adding 1 as a string of 1's and apply it to this modulo  
function to check when it becomes 0.




long long modulo(char b[],long long a)
{long long d=0,len,i,j,k;
len=strlen(b);
for (k=0;k {d*=10;
d+=b[k]-48;
d=d%a;
}



return d;



}



2. Any number ending in 3 will have the last digit as 1 if it is  
multiplied by 7.
Consider a case 13 ...let the required answer have 11.111. as its  
representation.13 x 7 = 91.
So subtracting the 3 digit of of 111.. by 91...we get  
111...11020Now we know that the ones digit of the required number is  
7...


Similarly, if the last digit of a ten's digit has to be '2'...The number  
has to be multiplied by 4.So we subtract 13 x 4 = 52 from.

1.02 to get 11...050...So we get the ten's digit as 4


Similarly, now for a number to end in 5...it has to be multiplied by  
5we subtract...65 from 111...105to get 111..1040...

Hundred's digit is 5
Similarly, now for a number to end in 4...it has to be multiplied by  
8 ... we subtract 104 from 111...104to get 111...000. and thus we end  
the process as we have got the remainder as 0.



Thus, our required answer is 13 x 8547 = 11


Now I want to know...that both the methods have similar complexity ie.  
O(k) where k is the number of 1's. However, 2nd is much more logical and  
complex. What does the company look for?



Suggest some better methods or make ammends.



Regards,



Mukul Gupta
3rd Year, Computer Engineering,
Netaji Subhas Institute of Technology.











On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com wrote:



yes ur wrong..1 is nt divisible by 23




On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:




This looks quite simple.



Every number ending in 3 follows a pattern.eg-



3 - 111



13 - 11



23 - 1 etc



we can find the reauired no. by :



suppose input no. is 33



In every case leave the no at 1's place(least significant) ie 3, In



33 you will be left with 3(after removal of 3 at first place).



Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)



= 12 ie ).



for 103 it is 3*(10+1) = 33 1's.





Correct if I am wrong.








On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:



 ADOBE asks the very basic C/C++ questions







 one of their toughest however was :







 every number ending in 3 has a multiple of the form 111...111







 eg 3 has 111



 13 has 11



 so on..







 find the algo for finding the number for an input number ending in 3.







 On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:































  hey, guys adobe is visiting our campus. So those who know questions



  that adobe asked in written or interview, please post here as it will



  be of great help (as adobe has visited some colleges already).



  Thank you 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 unsubscribe from this group, send email to  
algogeeks+unsubscr...@googlegroups.com.


For more options, visit this group at  
http://groups.google.com/group/algogeeks?hl=en.


















--


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 at  
http://groups.google.com/group/algogeeks?hl=en.














--


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 at  
http://groups.google.com/group/algogeeks?hl=en.





--
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe

2011-08-06 Thread nivedita arora
c round-
output que
given an expression - take it any ( 5+((4^5)+(6/7))+(4/8) )- aim was
to ensure that brackets are correctly placed

ds/algo-
1)java virtual machine has 8 byte instruction..calc its instruction
code size
2)there was a code given using lock ,wait and thread..had to tell abt
synchronisation and if code ws correct
3)determine a number is pallindrome or not - not allowed to convert it
to string or array..do it without it
4)a number ending in 3 ex 13 it will always hv a multiple which is
series of 1 ..13 has 111 ..23 has 11 now we hv to determine 1
series number for any give number ..also wht if the serires of 1 is
greater than range of long double ..
5)given a matrix NxN consisting of 0 and 1 st 0's are always before
1 ..tell the row hvng max number of 1 ..if  2 rows hv same number of
1 ..return any .
6)reverse LL
7)write a func to multiply 2 numbers without * . optimised code .
8)2 arrays A , B ..if there is a number in a number a in A and b in
B ..given a number val ..determine all pairs st a+b=val .optimised
code.


On Aug 6, 2:41 pm, vaibhavmitta...@gmail.com wrote:
 Mukul, in first approach instead of sending the string again and again u  
 can use the formula
 (a*b)%m = ((a%m)*(b%m))%m
 this way u can do sumthin like dis

 int count = 0, a = 1;
 while(a != 0) {
 count++;
 a = ((a*10)%n + 1) %n;

 }

 n later output a string consisting of count one's..

 Regards
 VM
 3rd Year, Computer Engineering,
 Netaji Subhas Institute of Technology.

 On , Mukul Gupta mukul.gupta...@gmail.com wrote:







  Manee, Nice Question.
  I have thought of two algorithms. I wanted to know how one judges them.  
  Both have similar time complexity but the 2nd one is slightly complex and  
  much more logical.
  1. Keeping on adding 1 as a string of 1's and apply it to this modulo  
  function to check when it becomes 0.
  long long modulo(char b[],long long a)
  {long long d=0,len,i,j,k;
  len=strlen(b);
  for (k=0;k {d*=10;
  d+=b[k]-48;
  d=d%a;
  }
  return d;
  }
  2. Any number ending in 3 will have the last digit as 1 if it is  
  multiplied by 7.
  Consider a case 13 ...let the required answer have 11.111. as its  
  representation.13 x 7 = 91.
  So subtracting the 3 digit of of 111.. by 91...we get  
  111...11020Now we know that the ones digit of the required number is  
  7...
  Similarly, if the last digit of a ten's digit has to be '2'...The number  
  has to be multiplied by 4.So we subtract 13 x 4 = 52 from.
  1.02 to get 11...050...So we get the ten's digit as 4
  Similarly, now for a number to end in 5...it has to be multiplied by  
  5we subtract...65 from 111...105to get 111..1040...
  Hundred's digit is 5
  Similarly, now for a number to end in 4...it has to be multiplied by  
  8 ... we subtract 104 from 111...104to get 111...000. and thus we end  
  the process as we have got the remainder as 0.
  Thus, our required answer is 13 x 8547 = 11
  Now I want to know...that both the methods have similar complexity ie.  
  O(k) where k is the number of 1's. However, 2nd is much more logical and  
  complex. What does the company look for?
  Suggest some better methods or make ammends.
  Regards,
  Mukul Gupta
  3rd Year, Computer Engineering,
  Netaji Subhas Institute of Technology.
  On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com wrote:
  yes ur wrong..1 is nt divisible by 23
  On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:
  This looks quite simple.
  Every number ending in 3 follows a pattern.eg-
  3 - 111
  13 - 11
  23 - 1 etc
  we can find the reauired no. by :
  suppose input no. is 33
  In every case leave the no at 1's place(least significant) ie 3, In
  33 you will be left with 3(after removal of 3 at first place).
  Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
  = 12 ie ).
  for 103 it is 3*(10+1) = 33 1's.
  Correct if I am wrong.
  On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
   ADOBE asks the very basic C/C++ questions

   one of their toughest however was :

   every number ending in 3 has a multiple of the form 111...111

   eg 3 has 111
   13 has 11
   so on..

   find the algo for finding the number for an input number ending in 3.

   On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:

hey, guys adobe is visiting our campus. So those who know questions
that adobe asked in written or interview, please post here as it will
be of great help (as adobe has visited some colleges already).
Thank you 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 unsubscribe from this group, send email to  
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at  
 http://groups.google.com/group/algogeeks?hl=en.
  --
  You received this 

Re: Re: [algogeeks] Re: adobe

2011-08-06 Thread Mukul Gupta
Vaibhav,
Hmm, fine that. I am more interested in the 2nd approach. The first approach
is simple brute force.

On Sat, Aug 6, 2011 at 3:11 PM, vaibhavmitta...@gmail.com wrote:

 Mukul, in first approach instead of sending the string again and again u
 can use the formula
 (a*b)%m = ((a%m)*(b%m))%m
 this way u can do sumthin like dis

 int count = 0, a = 1;
 while(a != 0) {
 count++;
 a = ((a*10)%n + 1) %n;
 }

 n later output a string consisting of count one's..

 Regards
 VM

 3rd Year, Computer Engineering,
 Netaji Subhas Institute of Technology.

 On , Mukul Gupta mukul.gupta...@gmail.com wrote:
  Manee, Nice Question.
  I have thought of two algorithms. I wanted to know how one judges them.
 Both have similar time complexity but the 2nd one is slightly complex and
 much more logical.
 
  1. Keeping on adding 1 as a string of 1's and apply it to this modulo
 function to check when it becomes 0.
 
 
  long long modulo(char b[],long long a)
  {long long d=0,len,i,j,k;
  len=strlen(b);
  for (k=0;k {d*=10;

  d+=b[k]-48;
  d=d%a;
  }
 
  return d;
 
  }
 
 
  2. Any number ending in 3 will have the last digit as 1 if it is
 multiplied by 7.
  Consider a case 13 ...let the required answer have 11.111. as its
 representation.13 x 7 = 91.
  So subtracting the 3 digit of of 111.. by 91...we get
 111...11020Now we know that the ones digit of the required number is
 7...
 
  Similarly, if the last digit of a ten's digit has to be '2'...The
 number has to be multiplied by 4.So we subtract 13 x 4 = 52 from.
  1.02 to get 11...050...So we get the ten's digit as 4
 
  Similarly, now for a number to end in 5...it has to be multiplied by
 5we subtract...65 from 111...105to get 111..1040...
  Hundred's digit is 5
  Similarly, now for a number to end in 4...it has to be multiplied by
 8 ... we subtract 104 from 111...104to get 111...000. and thus we end
 the  process as we have got the remainder as 0.
 
Thus, our required answer is 13 x 8547 = 11
 
  Now I want to know...that both the methods have similar complexity ie.
 O(k) where k is the number of 1's. However, 2nd is much more logical and
 complex. What does the company look for?
 
  Suggest some better methods or make ammends.
 
  Regards,
 
  Mukul Gupta
  3rd Year, Computer Engineering,
  Netaji Subhas Institute of Technology.
 
 
 
 
 
 
 
 
 
  On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com
 wrote:
 
  yes u r wrong..1 is nt divisible by 23
 
 
  On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:
 
 
  This looks quite simple.
 
  Every number ending in 3 follows a pattern.eg-
 
  3 - 111
 
  13 - 11
 
  23 - 1 etc
 
  we can find the reauired no. by :
 
  suppose input no. is 33
 
  In every case leave the no at 1's place(least significant) i.e. 3, In
 
  33 you will be left with 3(after removal of 3 at first place).
 
  Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 
  = 12 i.e  ).
 
  for 103 it is 3*(10+1) = 33 1's.
 
 
 
  Correct if I am wrong.
 
 
 
 
 
 
  On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
 
   ADOBE asks the very basic C/C++ questions
 
  
 
   one of their toughest however was :
 
  
 
   every number ending in 3 has a multiple of the form 111...111
 
  
 
   e.g 3 has 111
 
13 has 11
 
   so on..
 
  
 
   find the algo for finding the number for an input number ending in 3.
 
  
 
   On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
hey, guys adobe is visiting our campus. So those who know questions
 
that adobe asked in written or interview, please post here as it will
 
be of great help (as adobe has visited some colleges already).
 
Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  --
 
  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 at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
 
 
 
 
 
 
 
 
  --
 
  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 at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 

Re: Re: [algogeeks] Re: adobe

2011-08-06 Thread Ashish Sachdeva
mukul, pls explain my following doubts:
1. whats the need of subtracting the numbers, like u subtracted 91 then 52
etc...
2. the ones digit 7 is ok... didnt get how did u reach 4??

On Sat, Aug 6, 2011 at 3:22 PM, Mukul Gupta mukul.gupta...@gmail.comwrote:

 Vaibhav,
 Hmm, fine that. I am more interested in the 2nd approach. The first
 approach is simple brute force.

 On Sat, Aug 6, 2011 at 3:11 PM, vaibhavmitta...@gmail.com wrote:

 Mukul, in first approach instead of sending the string again and again u
 can use the formula
 (a*b)%m = ((a%m)*(b%m))%m
 this way u can do sumthin like dis

 int count = 0, a = 1;
 while(a != 0) {
 count++;
 a = ((a*10)%n + 1) %n;
 }

 n later output a string consisting of count one's..

 Regards
 VM

 3rd Year, Computer Engineering,
 Netaji Subhas Institute of Technology.

 On , Mukul Gupta mukul.gupta...@gmail.com wrote:
  Manee, Nice Question.
  I have thought of two algorithms. I wanted to know how one judges them.
 Both have similar time complexity but the 2nd one is slightly complex and
 much more logical.
 
  1. Keeping on adding 1 as a string of 1's and apply it to this modulo
 function to check when it becomes 0.
 
 
  long long modulo(char b[],long long a)
  {long long d=0,len,i,j,k;
  len=strlen(b);
  for (k=0;k {d*=10;

  d+=b[k]-48;
  d=d%a;
  }
 
  return d;
 
  }
 
 
  2. Any number ending in 3 will have the last digit as 1 if it is
 multiplied by 7.
  Consider a case 13 ...let the required answer have 11.111. as
 its representation.13 x 7 = 91.
  So subtracting the 3 digit of of 111.. by 91...we get
 111...11020Now we know that the ones digit of the required number is
 7...
 
  Similarly, if the last digit of a ten's digit has to be '2'...The
 number has to be multiplied by 4.So we subtract 13 x 4 = 52 from.
  1.02 to get 11...050...So we get the ten's digit as 4
 
  Similarly, now for a number to end in 5...it has to be multiplied by
 5we subtract...65 from 111...105to get 111..1040...
  Hundred's digit is 5
  Similarly, now for a number to end in 4...it has to be multiplied by
 8 ... we subtract 104 from 111...104to get 111...000. and thus we end
 the  process as we have got the remainder as 0.
 
Thus, our required answer is 13 x 8547 = 11
 
  Now I want to know...that both the methods have similar complexity ie.
 O(k) where k is the number of 1's. However, 2nd is much more logical and
 complex. What does the company look for?
 
  Suggest some better methods or make ammends.
 
  Regards,
 
  Mukul Gupta
  3rd Year, Computer Engineering,
  Netaji Subhas Institute of Technology.
 
 
 
 
 
 
 
 
 
  On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com
 wrote:
 
  yes u r wrong..1 is nt divisible by 23
 
 
  On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:
 
 
  This looks quite simple.
 
  Every number ending in 3 follows a pattern.eg-
 
  3 - 111
 
  13 - 11
 
  23 - 1 etc
 
  we can find the reauired no. by :
 
  suppose input no. is 33
 
  In every case leave the no at 1's place(least significant) i.e. 3, In
 
  33 you will be left with 3(after removal of 3 at first place).
 
  Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 
  = 12 i.e  ).
 
  for 103 it is 3*(10+1) = 33 1's.
 
 
 
  Correct if I am wrong.
 
 
 
 
 
 
  On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
 
   ADOBE asks the very basic C/C++ questions
 
  
 
   one of their toughest however was :
 
  
 
   every number ending in 3 has a multiple of the form 111...111
 
  
 
   e.g 3 has 111
 
13 has 11
 
   so on..
 
  
 
   find the algo for finding the number for an input number ending in 3.
 
  
 
   On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
hey, guys adobe is visiting our campus. So those who know questions
 
that adobe asked in written or interview, please post here as it
 will
 
be of great help (as adobe has visited some colleges already).
 
Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  --
 
  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 at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
 
 
 
 
 
 
 
 
  --
 
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks 

Re: Re: [algogeeks] Re: adobe

2011-08-06 Thread Ashish Sachdeva
thanx mukul for explanation checked it randomly on 123.. it works
fine...

On Sat, Aug 6, 2011 at 11:27 PM, Ashish Sachdeva ashish.asachd...@gmail.com
 wrote:

 mukul, pls explain my following doubts:
 1. whats the need of subtracting the numbers, like u subtracted 91 then 52
 etc...
 2. the ones digit 7 is ok... didnt get how did u reach 4??


 On Sat, Aug 6, 2011 at 3:22 PM, Mukul Gupta mukul.gupta...@gmail.comwrote:

 Vaibhav,
 Hmm, fine that. I am more interested in the 2nd approach. The first
 approach is simple brute force.

 On Sat, Aug 6, 2011 at 3:11 PM, vaibhavmitta...@gmail.com wrote:

 Mukul, in first approach instead of sending the string again and again u
 can use the formula
 (a*b)%m = ((a%m)*(b%m))%m
 this way u can do sumthin like dis

 int count = 0, a = 1;
 while(a != 0) {
 count++;
 a = ((a*10)%n + 1) %n;
 }

 n later output a string consisting of count one's..

 Regards
 VM

 3rd Year, Computer Engineering,
 Netaji Subhas Institute of Technology.

 On , Mukul Gupta mukul.gupta...@gmail.com wrote:
  Manee, Nice Question.
  I have thought of two algorithms. I wanted to know how one judges them.
 Both have similar time complexity but the 2nd one is slightly complex and
 much more logical.
 
  1. Keeping on adding 1 as a string of 1's and apply it to this modulo
 function to check when it becomes 0.
 
 
  long long modulo(char b[],long long a)
  {long long d=0,len,i,j,k;
  len=strlen(b);
  for (k=0;k {d*=10;

  d+=b[k]-48;
  d=d%a;
  }
 
  return d;
 
  }
 
 
  2. Any number ending in 3 will have the last digit as 1 if it is
 multiplied by 7.
  Consider a case 13 ...let the required answer have 11.111. as
 its representation.13 x 7 = 91.
  So subtracting the 3 digit of of 111.. by 91...we get
 111...11020Now we know that the ones digit of the required number is
 7...
 
  Similarly, if the last digit of a ten's digit has to be '2'...The
 number has to be multiplied by 4.So we subtract 13 x 4 = 52 from.
  1.02 to get 11...050...So we get the ten's digit as 4
 
  Similarly, now for a number to end in 5...it has to be multiplied
 by 5we subtract...65 from 111...105to get 111..1040...
  Hundred's digit is 5
  Similarly, now for a number to end in 4...it has to be multiplied
 by 8 ... we subtract 104 from 111...104to get 111...000. and thus we end
 the  process as we have got the remainder as 0.
 
Thus, our required answer is 13 x 8547 = 11
 
  Now I want to know...that both the methods have similar complexity ie.
 O(k) where k is the number of 1's. However, 2nd is much more logical and
 complex. What does the company look for?
 
  Suggest some better methods or make ammends.
 
  Regards,
 
  Mukul Gupta
  3rd Year, Computer Engineering,
  Netaji Subhas Institute of Technology.
 
 
 
 
 
 
 
 
 
  On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com
 wrote:
 
  yes u r wrong..1 is nt divisible by 23
 
 
  On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:
 
 
  This looks quite simple.
 
  Every number ending in 3 follows a pattern.eg-
 
  3 - 111
 
  13 - 11
 
  23 - 1 etc
 
  we can find the reauired no. by :
 
  suppose input no. is 33
 
  In every case leave the no at 1's place(least significant) i.e. 3, In
 
  33 you will be left with 3(after removal of 3 at first place).
 
  Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 
  = 12 i.e  ).
 
  for 103 it is 3*(10+1) = 33 1's.
 
 
 
  Correct if I am wrong.
 
 
 
 
 
 
  On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
 
   ADOBE asks the very basic C/C++ questions
 
  
 
   one of their toughest however was :
 
  
 
   every number ending in 3 has a multiple of the form 111...111
 
  
 
   e.g 3 has 111
 
13 has 11
 
   so on..
 
  
 
   find the algo for finding the number for an input number ending in 3.
 
  
 
   On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
hey, guys adobe is visiting our campus. So those who know questions
 
that adobe asked in written or interview, please post here as it
 will
 
be of great help (as adobe has visited some colleges already).
 
Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  --
 
  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 at
 

[algogeeks] Re: adobe

2011-08-05 Thread Manee
ADOBE asks the very basic C/C++ questions

one of their toughest however was :

every number ending in 3 has a multiple of the form 111...111

e.g 3 has 111
 13 has 11
so on..

find the algo for finding the number for an input number ending in 3.

On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 hey, guys adobe is visiting our campus. So those who know questions
 that adobe asked in written or interview, please post here as it will
 be of great help (as adobe has visited some colleges already).
 Thank you 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe

2011-08-05 Thread sumit
This looks quite simple.
Every number ending in 3 follows a pattern.eg-
3 - 111
13 - 11
23 - 1 etc
we can find the reauired no. by :
suppose input no. is 33
In every case leave the no at 1's place(least significant) i.e. 3, In
33 you will be left with 3(after removal of 3 at first place).
Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
= 12 i.e  ).
for 103 it is 3*(10+1) = 33 1's.

Correct if I am wrong.


On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
 ADOBE asks the very basic C/C++ questions

 one of their toughest however was :

 every number ending in 3 has a multiple of the form 111...111

 e.g 3 has 111
  13 has 11
 so on..

 find the algo for finding the number for an input number ending in 3.

 On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:







  hey, guys adobe is visiting our campus. So those who know questions
  that adobe asked in written or interview, please post here as it will
  be of great help (as adobe has visited some colleges already).
  Thank you 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe

2011-08-05 Thread sahil gujral
yes u r wrong..
1 is nt divisible by 23

On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:

 This looks quite simple.
 Every number ending in 3 follows a pattern.eg-
 3 - 111
 13 - 11
 23 - 1 etc
 we can find the reauired no. by :
 suppose input no. is 33
 In every case leave the no at 1's place(least significant) i.e. 3, In
 33 you will be left with 3(after removal of 3 at first place).
 Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 = 12 i.e  ).
 for 103 it is 3*(10+1) = 33 1's.

 Correct if I am wrong.


 On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
  ADOBE asks the very basic C/C++ questions
 
  one of their toughest however was :
 
  every number ending in 3 has a multiple of the form 111...111
 
  e.g 3 has 111
   13 has 11
  so on..
 
  find the algo for finding the number for an input number ending in 3.
 
  On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
 
 
 
 
 
 
   hey, guys adobe is visiting our campus. So those who know questions
   that adobe asked in written or interview, please post here as it will
   be of great help (as adobe has visited some colleges already).
   Thank you 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 unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-08-01 Thread Puneet Gautam
@ankit: not the last digit..!!
it will be (last digit -3) or (last digit -3-3) whichever is positive..

:)

On 7/31/11, Ankit Minglani ankit.mingl...@gmail.com wrote:
 yeah if it was a divisibility test then the question would have been too
 trivial ..
 the last digit after doing itoa will be the remainder .

 On Sat, Jul 30, 2011 at 11:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:

 i think solution of ankit is right !
 sorry even i forgot tht que ws not divisibility test ..but to get
 quotient :-|

 On Jul 30, 10:03 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  @roopam : i got the question all wrong. . .
 
  On Sat, Jul 30, 2011 at 10:01 PM, Roopam Poddar mailroo...@gmail.com
 wrote:
 
 
 
 
 
 
 
 
 
   The objective is to divide the number by 3 and not just check for it's
   divisibility.
   Adding the digits using itoa() and then repeated subtraction will
   check
 for
   it's divisibility by 3 and not give us the quotient.
   To get that you will have to carry out repeated subtraction on the
 number
   anyway.
   So whats the point?
 
   --
   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/-/BWTzYtcBhIgJ.
 
   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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Ankur Khurana
  Computer Science
  Netaji Subhas Institute Of Technology
  Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 The more you sweat in the field, the less you bleed in war.

 Ankit Minglani
 NITK Surathkal

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-08-01 Thread shubham
Hi,

we can show that

(x/3)  = (x/2) - (x/4) + (x/8) - (x/16) +  infinity

Proof:
let s1 = (x/2)+(x/8)+(x/32)+...infinity = (x/2)/(1-(1/4))   [Geometric 
Progression , common Ratio(r) = 1/4]
 s2 = (x/4)+(x/16)+(x/64)+...infinity = (x/4)/(1-(1/4))   [Geometric 
Progression , common Ratio(r) = 1/4]

now s1-s2 upon simplifying becomes (x/3)

Implementation:

x1=x1;
x2=x2;
s1=x1;
s2=x2;
while(x1 || x2){
  s1+=x12;
  s2+=x22;
  x1=2;
  x2=2;
}
return s1-s2;

If the number is not divisible by 3 the answer returned is the least integer 
function of (x/3)
correct me if i am wrong...

-- 
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/-/YZjVTMk5JvEJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-31 Thread Ankit Minglani
yeah if it was a divisibility test then the question would have been too
trivial ..
the last digit after doing itoa will be the remainder .

On Sat, Jul 30, 2011 at 11:52 AM, nivedita arora 
vivaciousnived...@gmail.com wrote:

 i think solution of ankit is right !
 sorry even i forgot tht que ws not divisibility test ..but to get
 quotient :-|

 On Jul 30, 10:03 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  @roopam : i got the question all wrong. . .
 
  On Sat, Jul 30, 2011 at 10:01 PM, Roopam Poddar mailroo...@gmail.com
 wrote:
 
 
 
 
 
 
 
 
 
   The objective is to divide the number by 3 and not just check for it's
   divisibility.
   Adding the digits using itoa() and then repeated subtraction will check
 for
   it's divisibility by 3 and not give us the quotient.
   To get that you will have to carry out repeated subtraction on the
 number
   anyway.
   So whats the point?
 
   --
   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/-/BWTzYtcBhIgJ.
 
   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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Ankur Khurana
  Computer Science
  Netaji Subhas Institute Of Technology
  Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
The more you sweat in the field, the less you bleed in war.

Ankit Minglani
NITK Surathkal

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread SAMM
Single bit shift...

int divide(int n)
{
n-=1;
n=1;
return n;
}

On 7/30/11, tech rascal techrascal...@gmail.com wrote:
 hw will u get the ans on repeated subtraction from the sum of the digits??
 I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the digits
 i.e, 2+7=9
 then I'll apply repeated subtraction on 9, so hw will i reach to the ans??


 On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:


 @brijesh-
 itoa basically converts integer to string ..we are using the fact tht
 a number is multiple of 3 if its sum is multiple of 3
 . we have int as string and we can traverse it ..for each character
 apply
  int sum+=*c-'0' (ankur missed the star :P)
 then on sum we use repeated subtraction...i hope its clear .

 we are using all this just coz we have to use itoa ..otherwise there
 are more methods (check my frst post )


 On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
  @ankur I didnt get this... could u or anyone please elaborate!
 
  On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 
 
 
 
 
 
 
   when you use itoa , what you get is a string. get the sum of all the
 digits
   , using c-'0' and then use repeated subtraction . . .
 
   On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
 sukhmeet2...@gmail.comwrote:
 
repeated subtraction !!
 
On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
vivaciousnived...@gmail.com wrote:
 
Without using /,% and * operators. write a function to divide a
 number
by 3. itoa() function is available.
 
all i cn thnk of is to use shift operator and addition ,
  x/3=e^(logx-
log3) or repetitive subtraction
 
but none of them uses itoa() ..ne idea how its done?
thnks !
 
--
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
 --
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   Ankur Khurana
   Computer Science
   Netaji Subhas Institute Of Technology
   Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Somnath Singh

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread aditi garg
@Samm : Im not able to understand ur logic...im not getting the correct
ans...can u explain the working taking n as 7?

On Sat, Jul 30, 2011 at 12:25 PM, SAMM somnath.nit...@gmail.com wrote:

 Single bit shift...

 int divide(int n)
 {
 n-=1;
 n=1;
 return n;
 }

 On 7/30/11, tech rascal techrascal...@gmail.com wrote:
  hw will u get the ans on repeated subtraction from the sum of the
 digits??
  I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the digits
  i.e, 2+7=9
  then I'll apply repeated subtraction on 9, so hw will i reach to the
 ans??
 
 
  On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:
 
 
  @brijesh-
  itoa basically converts integer to string ..we are using the fact tht
  a number is multiple of 3 if its sum is multiple of 3
  . we have int as string and we can traverse it ..for each character
  apply
   int sum+=*c-'0' (ankur missed the star :P)
  then on sum we use repeated subtraction...i hope its clear .
 
  we are using all this just coz we have to use itoa ..otherwise there
  are more methods (check my frst post )
 
 
  On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
   @ankur I didnt get this... could u or anyone please elaborate!
  
   On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  
  
  
  
  
  
  
when you use itoa , what you get is a string. get the sum of all the
  digits
, using c-'0' and then use repeated subtraction . . .
  
On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
  sukhmeet2...@gmail.comwrote:
  
 repeated subtraction !!
  
 On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:
  
 Without using /,% and * operators. write a function to divide a
  number
 by 3. itoa() function is available.
  
 all i cn thnk of is to use shift operator and addition ,
   x/3=e^(logx-
 log3) or repetitive subtraction
  
 but none of them uses itoa() ..ne idea how its done?
 thnks !
  
 --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
  --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
 
  --
  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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Ankit Minglani
#includestdio.h
#includestdlib.h
#includeconio.h
#includestring.h
#includemath.h

int multiply(int a,int b)
{

int i;
int temp=a;
printf(\na=%d b=%d\n,a,b);
for(i=1;ib;i++)
a+=temp;
printf(\nfinal a = %d,a);
return(a);

}

void main ()
{
int x,rem,quo=0,i,j;
char p[20];
clrscr();
scanf(%d,x);
itoa(x,p,3);

rem=(int)p[strlen(p)-1]-48;
printf(%dRemainder\n,rem);

for(i=strlen(p)-2,j=0;i=0;i--,j++)
{
printf(p[j] = %d,p[j]-48);
 //quo+=(p[j]-48)*pow(3,i);
quo+=multiply(p[j]-48,pow(3,i));
printf(\nquo=%d,quo);

}

printf(\nQuotient=%d,quo);

printf(\n%s,p);
getch();

}

taking base 3 will convert the number into the base 3 form ..
for example let x=100 the number to be divided by three.

so 100 in base 10 = 10201 in base 3 .
we get base 3 by consecutive divisions by 3 so the last number will always
be the remainder ie 1 .

rest   1 0 2 0 will be the quotient.
  |  |  |  |
index:3 2 1 0
so p[j]-48 will convert the char to integer and mutiply it wil 3 ^ power (
index )
the answer will be the quotient.


On Sat, Jul 30, 2011 at 12:15 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @Samm : Im not able to understand ur logic...im not getting the correct
 ans...can u explain the working taking n as 7?


 On Sat, Jul 30, 2011 at 12:25 PM, SAMM somnath.nit...@gmail.com wrote:

 Single bit shift...

 int divide(int n)
 {
 n-=1;
 n=1;
 return n;
 }

 On 7/30/11, tech rascal techrascal...@gmail.com wrote:
  hw will u get the ans on repeated subtraction from the sum of the
 digits??
  I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the
 digits
  i.e, 2+7=9
  then I'll apply repeated subtraction on 9, so hw will i reach to the
 ans??
 
 
  On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:
 
 
  @brijesh-
  itoa basically converts integer to string ..we are using the fact tht
  a number is multiple of 3 if its sum is multiple of 3
  . we have int as string and we can traverse it ..for each character
  apply
   int sum+=*c-'0' (ankur missed the star :P)
  then on sum we use repeated subtraction...i hope its clear .
 
  we are using all this just coz we have to use itoa ..otherwise there
  are more methods (check my frst post )
 
 
  On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
   @ankur I didnt get this... could u or anyone please elaborate!
  
   On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  
  
  
  
  
  
  
when you use itoa , what you get is a string. get the sum of all
 the
  digits
, using c-'0' and then use repeated subtraction . . .
  
On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
  sukhmeet2...@gmail.comwrote:
  
 repeated subtraction !!
  
 On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:
  
 Without using /,% and * operators. write a function to divide a
  number
 by 3. itoa() function is available.
  
 all i cn thnk of is to use shift operator and addition ,
   x/3=e^(logx-
 log3) or repetitive subtraction
  
 but none of them uses itoa() ..ne idea how its done?
 thnks !
  
 --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
  --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
 
  --
  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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post 

Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Puneet Gautam
I think the whole point and advantage of using itoa is to make the
code suitable for larger integer inputs..

eg: if i/p is: 32765 , itoa gives 32765, we take each sum=3+2+7+6+5=
23 and then use repeated subtraction...

Repeated subtraction on 2 digit no. is much faster than on 5 digit one..!!

Hence, itoa becomes useful..!

Thanks..

On 7/30/11, Ankit Minglani ankit.mingl...@gmail.com wrote:
 #includestdio.h
 #includestdlib.h
 #includeconio.h
 #includestring.h
 #includemath.h

 int multiply(int a,int b)
 {

 int i;
 int temp=a;
 printf(\na=%d b=%d\n,a,b);
 for(i=1;ib;i++)
 a+=temp;
 printf(\nfinal a = %d,a);
 return(a);

 }

 void main ()
 {
 int x,rem,quo=0,i,j;
 char p[20];
 clrscr();
 scanf(%d,x);
 itoa(x,p,3);

 rem=(int)p[strlen(p)-1]-48;
 printf(%dRemainder\n,rem);

 for(i=strlen(p)-2,j=0;i=0;i--,j++)
 {
 printf(p[j] = %d,p[j]-48);
  //quo+=(p[j]-48)*pow(3,i);
 quo+=multiply(p[j]-48,pow(3,i));
 printf(\nquo=%d,quo);

 }

 printf(\nQuotient=%d,quo);

 printf(\n%s,p);
 getch();

 }

 taking base 3 will convert the number into the base 3 form ..
 for example let x=100 the number to be divided by three.

 so 100 in base 10 = 10201 in base 3 .
 we get base 3 by consecutive divisions by 3 so the last number will always
 be the remainder ie 1 .

 rest   1 0 2 0 will be the quotient.
   |  |  |  |
 index:3 2 1 0
 so p[j]-48 will convert the char to integer and mutiply it wil 3 ^ power (
 index )
 the answer will be the quotient.


 On Sat, Jul 30, 2011 at 12:15 AM, aditi garg
 aditi.garg.6...@gmail.comwrote:

 @Samm : Im not able to understand ur logic...im not getting the correct
 ans...can u explain the working taking n as 7?


 On Sat, Jul 30, 2011 at 12:25 PM, SAMM somnath.nit...@gmail.com wrote:

 Single bit shift...

 int divide(int n)
 {
 n-=1;
 n=1;
 return n;
 }

 On 7/30/11, tech rascal techrascal...@gmail.com wrote:
  hw will u get the ans on repeated subtraction from the sum of the
 digits??
  I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the
 digits
  i.e, 2+7=9
  then I'll apply repeated subtraction on 9, so hw will i reach to the
 ans??
 
 
  On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:
 
 
  @brijesh-
  itoa basically converts integer to string ..we are using the fact tht
  a number is multiple of 3 if its sum is multiple of 3
  . we have int as string and we can traverse it ..for each character
  apply
   int sum+=*c-'0' (ankur missed the star :P)
  then on sum we use repeated subtraction...i hope its clear .
 
  we are using all this just coz we have to use itoa ..otherwise there
  are more methods (check my frst post )
 
 
  On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
   @ankur I didnt get this... could u or anyone please elaborate!
  
   On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  
  
  
  
  
  
  
when you use itoa , what you get is a string. get the sum of all
 the
  digits
, using c-'0' and then use repeated subtraction . . .
  
On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
  sukhmeet2...@gmail.comwrote:
  
 repeated subtraction !!
  
 On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:
  
 Without using /,% and * operators. write a function to divide a
  number
 by 3. itoa() function is available.
  
 all i cn thnk of is to use shift operator and addition ,
   x/3=e^(logx-
 log3) or repetitive subtraction
  
 but none of them uses itoa() ..ne idea how its done?
 thnks !
  
 --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
  --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
 
  --
  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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  You received this message because you 

Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Abhishek Gupta
let the number be num
so code is this

int ans=0;
while(num=3)
{
num=num-3;
ans++;
}

No need to use itoa. This is simple division algo based on subtraction.



On Sat, Jul 30, 2011 at 2:09 PM, Ankit Minglani ankit.mingl...@gmail.comwrote:

 #includestdio.h
 #includestdlib.h
 #includeconio.h
 #includestring.h
 #includemath.h

 int multiply(int a,int b)
 {

 int i;
 int temp=a;
 printf(\na=%d b=%d\n,a,b);
 for(i=1;ib;i++)
 a+=temp;
 printf(\nfinal a = %d,a);
 return(a);

 }

 void main ()
 {
 int x,rem,quo=0,i,j;
 char p[20];
 clrscr();
 scanf(%d,x);
 itoa(x,p,3);

 rem=(int)p[strlen(p)-1]-48;
 printf(%dRemainder\n,rem);

 for(i=strlen(p)-2,j=0;i=0;i--,j++)
 {
 printf(p[j] = %d,p[j]-48);
  //quo+=(p[j]-48)*pow(3,i);
 quo+=multiply(p[j]-48,pow(3,i));
 printf(\nquo=%d,quo);

 }

 printf(\nQuotient=%d,quo);

 printf(\n%s,p);
 getch();

 }

 taking base 3 will convert the number into the base 3 form ..
 for example let x=100 the number to be divided by three.

 so 100 in base 10 = 10201 in base 3 .
 we get base 3 by consecutive divisions by 3 so the last number will always
 be the remainder ie 1 .

 rest   1 0 2 0 will be the quotient.
   |  |  |  |
 index:3 2 1 0
 so p[j]-48 will convert the char to integer and mutiply it wil 3 ^ power (
 index )
 the answer will be the quotient.



 On Sat, Jul 30, 2011 at 12:15 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @Samm : Im not able to understand ur logic...im not getting the correct
 ans...can u explain the working taking n as 7?


 On Sat, Jul 30, 2011 at 12:25 PM, SAMM somnath.nit...@gmail.com wrote:

 Single bit shift...

 int divide(int n)
 {
 n-=1;
 n=1;
 return n;
 }

 On 7/30/11, tech rascal techrascal...@gmail.com wrote:
  hw will u get the ans on repeated subtraction from the sum of the
 digits??
  I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the
 digits
  i.e, 2+7=9
  then I'll apply repeated subtraction on 9, so hw will i reach to the
 ans??
 
 
  On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:
 
 
  @brijesh-
  itoa basically converts integer to string ..we are using the fact tht
  a number is multiple of 3 if its sum is multiple of 3
  . we have int as string and we can traverse it ..for each character
  apply
   int sum+=*c-'0' (ankur missed the star :P)
  then on sum we use repeated subtraction...i hope its clear .
 
  we are using all this just coz we have to use itoa ..otherwise there
  are more methods (check my frst post )
 
 
  On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
   @ankur I didnt get this... could u or anyone please elaborate!
  
   On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:
  
  
  
  
  
  
  
when you use itoa , what you get is a string. get the sum of all
 the
  digits
, using c-'0' and then use repeated subtraction . . .
  
On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
  sukhmeet2...@gmail.comwrote:
  
 repeated subtraction !!
  
 On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:
  
 Without using /,% and * operators. write a function to divide a
  number
 by 3. itoa() function is available.
  
 all i cn thnk of is to use shift operator and addition ,
   x/3=e^(logx-
 log3) or repetitive subtraction
  
 but none of them uses itoa() ..ne idea how its done?
 thnks !
  
 --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
  --
 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 at
http://groups.google.com/group/algogeeks?hl=en.
  
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
 
  --
  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 at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  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 

Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Roopam Poddar
The objective is to divide the number by 3 and not just check for it's 
divisibility.
Adding the digits using itoa() and then repeated subtraction will check for 
it's divisibility by 3 and not give us the quotient.
To get that you will have to carry out repeated subtraction on the number 
anyway.
So whats the point?

-- 
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/-/BWTzYtcBhIgJ.
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Ankur Khurana
@roopam : i got the question all wrong. . .

On Sat, Jul 30, 2011 at 10:01 PM, Roopam Poddar mailroo...@gmail.comwrote:

 The objective is to divide the number by 3 and not just check for it's
 divisibility.
 Adding the digits using itoa() and then repeated subtraction will check for
 it's divisibility by 3 and not give us the quotient.
 To get that you will have to carry out repeated subtraction on the number
 anyway.
 So whats the point?

 --
 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/-/BWTzYtcBhIgJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Puneet Gautam
@roopam: Thats what i am saying... the function itoa only gives you
the remainder, it doesnt provide quotient..we need to do repeated
subtraction for that...




On 7/30/11, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 @roopam : i got the question all wrong. . .

 On Sat, Jul 30, 2011 at 10:01 PM, Roopam Poddar mailroo...@gmail.comwrote:

 The objective is to divide the number by 3 and not just check for it's
 divisibility.
 Adding the digits using itoa() and then repeated subtraction will check
 for
 it's divisibility by 3 and not give us the quotient.
 To get that you will have to carry out repeated subtraction on the number
 anyway.
 So whats the point?

 --
 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/-/BWTzYtcBhIgJ.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe written round que

2011-07-30 Thread nivedita arora
i think solution of ankit is right !
sorry even i forgot tht que ws not divisibility test ..but to get
quotient :-|

On Jul 30, 10:03 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 @roopam : i got the question all wrong. . .

 On Sat, Jul 30, 2011 at 10:01 PM, Roopam Poddar mailroo...@gmail.comwrote:









  The objective is to divide the number by 3 and not just check for it's
  divisibility.
  Adding the digits using itoa() and then repeated subtraction will check for
  it's divisibility by 3 and not give us the quotient.
  To get that you will have to carry out repeated subtraction on the number
  anyway.
  So whats the point?

  --
  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/-/BWTzYtcBhIgJ.

  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 at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe written round que

2011-07-29 Thread nivedita arora
hmm ok got it . ..i can take gt sum of digits without having the
number as string as well . i din exactly gt the whole point of using
strings.
they shud hv mentioned it explicitly i guess . .
though thanks ankur

On Jul 30, 1:15 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 you shouldn't be using itoa anyways. It is not a part of ANSI C. you might
 like to use sprintf . you can search for reference on cplusplus.com

 On Sat, Jul 30, 2011 at 1:36 AM, aditi garg aditi.garg.6...@gmail.comwrote:









  @Ankur: I dont know how to use itoa function...can u please write a small
  code...for eg in dis ques only can u tell me how to use itoa to get sum...

  On Sat, Jul 30, 2011 at 1:13 AM, Ankur Khurana 
  ankur.kkhur...@gmail.comwrote:

  when you use itoa , what you get is a string. get the sum of all the
  digits , using c-'0' and then use repeated subtraction . . .

  On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
  sukhmeet2...@gmail.comwrote:

  repeated subtraction !!

  On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:

  Without using /,% and * operators. write a function to divide a number
  by 3. itoa() function is available.

  all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
  log3) or repetitive subtraction

  but none of them uses itoa() ..ne idea how its done?
  thnks !

  --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

   --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

  --
  Ankur Khurana
  Computer Science
  Netaji Subhas Institute Of Technology
  Delhi.

   --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

  --
  Aditi Garg
  Undergraduate Student
  Electronics  Communication Divison
  NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
  Sector 3, Dwarka
  New Delhi

   --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe written round que

2011-07-29 Thread Amit
well,well,well...
a=x1;
b=x2;
c=(a+b)1;
d=x3;
x=c+d;
actually i used the fact- 1/3 = 3/9 = ((1/2)+(1/4))/2 + 1/8   

On Jul 30, 1:37 am, nivedita arora vivaciousnived...@gmail.com
wrote:
 hmm ok got it . ..i can take gt sum of digits without having the
 number as string as well . i din exactly gt the whole point of using
 strings.
 they shud hv mentioned it explicitly i guess . .
 though thanks ankur

 On Jul 30, 1:15 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:







  you shouldn't be using itoa anyways. It is not a part of ANSI C. you might
  like to use sprintf . you can search for reference on cplusplus.com

  On Sat, Jul 30, 2011 at 1:36 AM, aditi garg 
  aditi.garg.6...@gmail.comwrote:

   @Ankur: I dont know how to use itoa function...can u please write a small
   code...for eg in dis ques only can u tell me how to use itoa to get sum...

   On Sat, Jul 30, 2011 at 1:13 AM, Ankur Khurana 
   ankur.kkhur...@gmail.comwrote:

   when you use itoa , what you get is a string. get the sum of all the
   digits , using c-'0' and then use repeated subtraction . . .

   On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
   sukhmeet2...@gmail.comwrote:

   repeated subtraction !!

   On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
   vivaciousnived...@gmail.com wrote:

   Without using /,% and * operators. write a function to divide a number
   by 3. itoa() function is available.

   all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
   log3) or repetitive subtraction

   but none of them uses itoa() ..ne idea how its done?
   thnks !

   --
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

    --
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

   --
   Ankur Khurana
   Computer Science
   Netaji Subhas Institute Of Technology
   Delhi.

    --
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

   --
   Aditi Garg
   Undergraduate Student
   Electronics  Communication Divison
   NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
   Sector 3, Dwarka
   New Delhi

    --
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

  --
  Ankur Khurana
  Computer Science
  Netaji Subhas Institute Of Technology
  Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread aditi garg
ur expression forms 4/8=1/2 and not 1/3...

On Sat, Jul 30, 2011 at 3:18 AM, Amit amitbaranwa...@gmail.com wrote:

 well,well,well...
 a=x1;
 b=x2;
 c=(a+b)1;
 d=x3;
 x=c+d;
 actually i used the fact- 1/3 = 3/9 = ((1/2)+(1/4))/2 + 1/8   

 On Jul 30, 1:37 am, nivedita arora vivaciousnived...@gmail.com
 wrote:
  hmm ok got it . ..i can take gt sum of digits without having the
  number as string as well . i din exactly gt the whole point of using
  strings.
  they shud hv mentioned it explicitly i guess . .
  though thanks ankur
 
  On Jul 30, 1:15 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 
 
 
 
 
 
 
   you shouldn't be using itoa anyways. It is not a part of ANSI C. you
 might
   like to use sprintf . you can search for reference on cplusplus.com
 
   On Sat, Jul 30, 2011 at 1:36 AM, aditi garg aditi.garg.6...@gmail.com
 wrote:
 
@Ankur: I dont know how to use itoa function...can u please write a
 small
code...for eg in dis ques only can u tell me how to use itoa to get
 sum...
 
On Sat, Jul 30, 2011 at 1:13 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:
 
when you use itoa , what you get is a string. get the sum of all the
digits , using c-'0' and then use repeated subtraction . . .
 
On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
 sukhmeet2...@gmail.comwrote:
 
repeated subtraction !!
 
On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
vivaciousnived...@gmail.com wrote:
 
Without using /,% and * operators. write a function to divide a
 number
by 3. itoa() function is available.
 
all i cn thnk of is to use shift operator and addition ,
  x/3=e^(logx-
log3) or repetitive subtraction
 
but none of them uses itoa() ..ne idea how its done?
thnks !
 
--
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
 --
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
 
 --
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
--
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi
 
 --
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   Ankur Khurana
   Computer Science
   Netaji Subhas Institute Of Technology
   Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread Sudhir mishra
int divideby3 (int num)
{
  int sum = 0;
  while (num  3) {
sum += num  2;
num = (num  2) + (num  3);
  }
  if (num == 3) ++sum;
  return sum;
}


Thanks  Regards...*
รυ∂んเя мเรんяค*

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe written round que

2011-07-29 Thread brijesh
@ankur I didnt get this... could u or anyone please elaborate!

On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 when you use itoa , what you get is a string. get the sum of all the digits
 , using c-'0' and then use repeated subtraction . . .

 On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh sukhmeet2...@gmail.comwrote:









  repeated subtraction !!

  On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:

  Without using /,% and * operators. write a function to divide a number
  by 3. itoa() function is available.

  all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
  log3) or repetitive subtraction

  but none of them uses itoa() ..ne idea how its done?
  thnks !

  --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

   --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread ananth sharma
shift the number to left two times and subtract once... I.e.

Int x=num;
x=x2;
x-=num;

On 7/30/11, brijesh brijeshupadhyay...@gmail.com wrote:
 @ankur I didnt get this... could u or anyone please elaborate!

 On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 when you use itoa , what you get is a string. get the sum of all the
 digits
 , using c-'0' and then use repeated subtraction . . .

 On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh
 sukhmeet2...@gmail.comwrote:









  repeated subtraction !!

  On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
  vivaciousnived...@gmail.com wrote:

  Without using /,% and * operators. write a function to divide a number
  by 3. itoa() function is available.

  all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
  log3) or repetitive subtraction

  but none of them uses itoa() ..ne idea how its done?
  thnks !

  --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

   --
  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 at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
ThanksRegards,
Anantha Krishna Sharma.Kalle
eMail-Id:ananthakrishna.ka...@gmail.com
Ph. No:+91-9036116130

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: adobe written round que

2011-07-29 Thread nivedita arora

@brijesh-
itoa basically converts integer to string ..we are using the fact tht
a number is multiple of 3 if its sum is multiple of 3
. we have int as string and we can traverse it ..for each character
apply
 int sum+=*c-'0' (ankur missed the star :P)
then on sum we use repeated subtraction...i hope its clear .

we are using all this just coz we have to use itoa ..otherwise there
are more methods (check my frst post )


On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
 @ankur I didnt get this... could u or anyone please elaborate!

 On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:







  when you use itoa , what you get is a string. get the sum of all the digits
  , using c-'0' and then use repeated subtraction . . .

  On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
  sukhmeet2...@gmail.comwrote:

   repeated subtraction !!

   On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
   vivaciousnived...@gmail.com wrote:

   Without using /,% and * operators. write a function to divide a number
   by 3. itoa() function is available.

   all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
   log3) or repetitive subtraction

   but none of them uses itoa() ..ne idea how its done?
   thnks !

   --
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

    --
   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 at
  http://groups.google.com/group/algogeeks?hl=en.

  --
  Ankur Khurana
  Computer Science
  Netaji Subhas Institute Of Technology
  Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread tech rascal
hw will u get the ans on repeated subtraction from the sum of the digits??
I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the digits
i.e, 2+7=9
then I'll apply repeated subtraction on 9, so hw will i reach to the ans??


On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora 
vivaciousnived...@gmail.com wrote:


 @brijesh-
 itoa basically converts integer to string ..we are using the fact tht
 a number is multiple of 3 if its sum is multiple of 3
 . we have int as string and we can traverse it ..for each character
 apply
  int sum+=*c-'0' (ankur missed the star :P)
 then on sum we use repeated subtraction...i hope its clear .

 we are using all this just coz we have to use itoa ..otherwise there
 are more methods (check my frst post )


 On Jul 30, 4:34 am, brijesh brijeshupadhyay...@gmail.com wrote:
  @ankur I didnt get this... could u or anyone please elaborate!
 
  On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 
 
 
 
 
 
 
   when you use itoa , what you get is a string. get the sum of all the
 digits
   , using c-'0' and then use repeated subtraction . . .
 
   On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
 sukhmeet2...@gmail.comwrote:
 
repeated subtraction !!
 
On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
vivaciousnived...@gmail.com wrote:
 
Without using /,% and * operators. write a function to divide a
 number
by 3. itoa() function is available.
 
all i cn thnk of is to use shift operator and addition ,
  x/3=e^(logx-
log3) or repetitive subtraction
 
but none of them uses itoa() ..ne idea how its done?
thnks !
 
--
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
 --
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 at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   Ankur Khurana
   Computer Science
   Netaji Subhas Institute Of Technology
   Delhi.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Ques

2011-07-21 Thread Ankur Khurana
I gave an O(N)  solution in a different thread by same author for this
question...

On Thu, Jul 21, 2011 at 6:08 PM, Abhi abhi123khat...@gmail.com wrote:

 My solution for this :

 #includestdio.h
 int max(int a,int b)
 {
 return ab?a:b;
 }

 int main()
 {
 char str[] = abcdab;
 int count=0,max1=0;
 int i=0,j,k;
 int hash[26];
 for(i=0;i26;i++)
 hash[i]=-1;
 for(i=0;istrlen(str);i++)
 {
 count=0;
 for(j=i;hash[str[j]-'a']==-1;j++)
 {

 hash[str[j]-'a'] = 1;
 count++;
 }

 max1=max(count,max1);
 for(k=0;k26;k++)
 hash[k]=-1;


 }
 printf(%d ,max1);
 getch();
 return 0;
 }

 Worst case running time : O(n^2)  when string is of the form abcdeabcde.

 Does there exist an O(n) solution for this?

 --
 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/-/HoCrZFVsRh8J.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Ques

2011-07-21 Thread Ankur Khurana
Sorry , solution nahi dekha tha tera maine.

On Thu, Jul 21, 2011 at 9:29 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 I gave an O(N)  solution in a different thread by same author for this
 question...


 On Thu, Jul 21, 2011 at 6:08 PM, Abhi abhi123khat...@gmail.com wrote:

 My solution for this :

 #includestdio.h
 int max(int a,int b)
 {
 return ab?a:b;
 }

 int main()
 {
 char str[] = abcdab;
 int count=0,max1=0;
 int i=0,j,k;
 int hash[26];
 for(i=0;i26;i++)
 hash[i]=-1;
 for(i=0;istrlen(str);i++)
 {
 count=0;
 for(j=i;hash[str[j]-'a']==-1;j++)
 {

 hash[str[j]-'a'] = 1;
 count++;
 }

 max1=max(count,max1);
 for(k=0;k26;k++)
 hash[k]=-1;


 }
 printf(%d ,max1);
 getch();
 return 0;
 }

 Worst case running time : O(n^2)  when string is of the form abcdeabcde.

 Does there exist an O(n) solution for this?

 --
 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/-/HoCrZFVsRh8J.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe Ques

2011-07-21 Thread Ankur Khurana
but mine was different , check kar liyo

On Thu, Jul 21, 2011 at 10:06 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 Sorry , solution nahi dekha tha tera maine.


 On Thu, Jul 21, 2011 at 9:29 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 I gave an O(N)  solution in a different thread by same author for this
 question...


 On Thu, Jul 21, 2011 at 6:08 PM, Abhi abhi123khat...@gmail.com wrote:

 My solution for this :

 #includestdio.h
 int max(int a,int b)
 {
 return ab?a:b;
 }

 int main()
 {
 char str[] = abcdab;
 int count=0,max1=0;
 int i=0,j,k;
 int hash[26];
 for(i=0;i26;i++)
 hash[i]=-1;
 for(i=0;istrlen(str);i++)
 {
 count=0;
 for(j=i;hash[str[j]-'a']==-1;j++)
 {

 hash[str[j]-'a'] = 1;
 count++;
 }

 max1=max(count,max1);
 for(k=0;k26;k++)
 hash[k]=-1;


 }
 printf(%d ,max1);
 getch();
 return 0;
 }

 Worst case running time : O(n^2)  when string is of the form
 abcdeabcde.

 Does there exist an O(n) solution for this?

 --
 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/-/HoCrZFVsRh8J.

 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 at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Adobe - Algorithm

2011-06-07 Thread Anand
http://anandtechblog.blogspot.com/2011/06/in-place-shuffle.html

On Mon, Jan 10, 2011 at 9:06 AM, anurag.singh anurag.x.si...@gmail.comwrote:

 OK. I hope following should do the needful.
 Input:
 a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN
 Output:
 a1,b1,a2,b2,a3,b3,a4,b4,..aN,bN.

 If we notice, there is a pattern for all elements while shuffling.
 For all elements from 1st half portion (a1 to aN)
 a[i] is moved to a[2*i] where 0= i = N [say array name is a]
 i.e.
 a[0] is moved to a[0] (for i=0, i = 2*i =0)
 a[1] is moved to a[2]
 a[2] is moved to a[4]
 a[3] is moved to a[6]
 ..
 
 For 2nd half, same is true from opposite (OR if we see array
 inverted,b1 to bN behaves same as a's)
 In other words, keeping array as is, 2nd half of the array (b1 to bN)
 goes like this


 a[i] is moved to a[n-2*(n-i)] where N  i  2N
 i.e. (Assuming 2nd half array starting with index i=7, so total array
 size 12)


 a[7] moved to a[1]
 a[8] moved to a[3]
 a[9] moved to a[5]


 overall as example:
 Input
 a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10],
 a[11]
 Output:
 a[0], a[6], a[1], a[7], a[2], a[8], a[3], a[9], a[4], a[10], a[5],
 a[11]


 And I believe it's pretty straightforward to implement this. using
 only few extra variables [not dependent on array size](Based on
 implimentation).
 So, O(n) time and O(1) space.


 Alg: [assuming all elements are  0)

 Negate all elements (a[i] = -1 * a[i];)
 current_index = 0;
 current_element=A[0];
 do
if current_index = n/2 then
   to_index = 2*current_index
else
   to_index = (size -1) - 2*(size - 1 - current_index)
end if
current_element = A[to_index];
 A[to_index] = -1 * A[current_index];
if current_element  0 then
  to_index = index of next negative element.
current_index = to_index;
 while A[current_index]  0

 Algo can be modified to check in other cases like when elements can be
 negative also, OR elements are characters, strings.
 There can be different ways to track if all elements are processed or
 not, depending on problem.
 e.g. if negative elements are also in input then,
 Add some very very negative no to all elements say -5 and while
 assigning it to to_index, adding 5
 If element are characters, string then attach some keyword (prefix or
 suffix) to each element,
 while assigning it to to_index, remove the attachment.

 Please advise if you find any issue with this.


 On Jan 10, 5:51 pm, juver++ avpostni...@gmail.com wrote:
  There is only one single array.

 --
 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 at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Interview Question

2011-02-22 Thread Gaurav Gupta
Minimum number of cuts can be 1 and maximum can be n-1. Lets assume c
number of cuts 1= c = n-1 are required.
So brute force says :

iterate c 1 to n-1
and for these c cuts there would be (n-1)Cc combinations because there
are n-1 places in a1, a2,a3...an where these cuts can appear.
complexity would be order of n!.

On Jan 13, 11:34 pm, Jammy xujiayiy...@gmail.com wrote:
 brute force approach

 On Jan 12, 5:42 am, AKS abhijeet.k.s...@gmail.com wrote:







  can someone just expain the plain simple logic used to solve this
  problem ??
  Cdn't get it seeing the code

  On Jan 11, 10:08 pm, Jammy xujiayiy...@gmail.com wrote:

   There are apparently more than one way to make the cuts(totally it'll
   still be three). The code only outputs first possible.

   On Jan 11, 10:42 am, Arpit Sood soodfi...@gmail.com wrote:

oh, i considered that the sum of the total numbers for both john and 
mary to
be equal after the whole division process. I am not considering pair 
wise
sum.
That's why for input
1 4 5 6 2 2 2 2 4 5 6 1 1 7 8 8 1 7
segments should be:
(John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 1 7 8 -- (John) 8 1 7
minimum cuts made are 2

but if we consider pair wise cuts as done by you, output will be :
(John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 --- (john) 1 7 8 -- 
(Mary) 8 1
7
minimum cuts = 3

On Tue, Jan 11, 2011 at 8:38 PM, Jammy xujiayiy...@gmail.com wrote:
 @Arpit Please explain your solution to me. As far as I understand,
 every alternate of two person should sum up equally.  Which means
 every pair of (john, mary) has the same sum for john and mary.

 On Jan 11, 2:55 am, Arpit Sood soodfi...@gmail.com wrote:
  @jammy your code isnt working for the mentioned test case.
  One simple approach is to go greedy on the test data, but that wont
 always
  give the optimum answer.

  On Tue, Jan 11, 2011 at 1:11 PM, Arpit Sood soodfi...@gmail.com 
  wrote:
   the output for first test case is wrong it should be
   (John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 1 7 8 -- (Mary) 8 1 
   7
   minimum cuts made are 2

   On Tue, Jan 11, 2011 at 10:04 AM, Jammy xujiayiy...@gmail.com 
   wrote:

   (a) it is intuitive to see we need to make a recursive function 
   which
   takes  the following arguments:
      1) array,
      2) start index,
      3) length of the array,
      4) a sentinel indicating if it is the first half or second 
   half
      5) a sum if it is the second half
      6) number of cuts so far
      7) a global minimal cuts

   So my recursive function looks something like this,
   void cutMinHelper(int *arr, int start, int len, bool isFirst, 
   int sum,
   int cut, int minV, vectorint res);

   and its wrapper just takes two arguments
   void cutMin(int *arr, int len);

   The idea is to differentiate the first half and second half. If 
   it's
   the first half, you need make all possible cuts, and recursive 
   call
   itself to get the second done. If it's the second half, you need
   calculate sums all the way to the end. Break out of the loop if 
   it
   equals to the sum of the first part. And then recursively call 
   itself
   to get the first half done.

   I hope my code explains the idea...Please report any bugs you 
   find :)

   vectorint minVector; //storing the cuts

   void cutMin(int *arr, int len){
          int cut=0, minV = INT_MAX;
          vectorint res;
          cutMinHelper(arr, 0, len, true, 0, cut, minV, res);
          if(minVINT_MAX){
                  coutminimal cut isminVendl;
          }

   }

   void cutMinHelper(int *arr, int start, int len, bool isFirst, 
   int sum,
   int cut, int minV, vectorint res){
          if(isFirst  startlen){
                  if(start==0) cut = 0;
                  int sum = arr[start];
                  cut++;
                  for(int i = start+1; i  len; i++){
                          vectorint addOne = res;
                          addOne.push_back(i-1);
                          cutMinHelper(arr, i , len, !isFirst, sum, 
   cut,
   minV, addOne);
                          sum += arr[i];
                  }
          }
          if(!isFirst  startlen){
              int i, sum2 = 0;
                  for(i = start; i  len; i++){
                          sum2 += arr[i];
                          if(sum2 == sum){
                                  break;
                          }
                  }
                  if( i==len-1  sum2==sum) {
                          if(cutminV){
                                  minV = cut;
                                  minVector = res;
                          }
                 

[algogeeks] Re: Adobe Interview

2011-01-14 Thread bittu
You have N computers and [Ca, Cb] means a is connected to b and this
connectivity is symmetric and transitive. then write a program which
checks that all computers are interconnected and talk two each other?


Regards
Shashank

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Interview

2011-01-14 Thread juver++
Simple BFS or DFS solves this problem. 

-- 
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 at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Adobe Interview Question

2011-01-12 Thread AKS
can someone just expain the plain simple logic used to solve this
problem ??
Cdn't get it seeing the code

On Jan 11, 10:08 pm, Jammy xujiayiy...@gmail.com wrote:
 There are apparently more than one way to make the cuts(totally it'll
 still be three). The code only outputs first possible.

 On Jan 11, 10:42 am, Arpit Sood soodfi...@gmail.com wrote:







  oh, i considered that the sum of the total numbers for both john and mary to
  be equal after the whole division process. I am not considering pair wise
  sum.
  That's why for input
  1 4 5 6 2 2 2 2 4 5 6 1 1 7 8 8 1 7
  segments should be:
  (John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 1 7 8 -- (John) 8 1 7
  minimum cuts made are 2

  but if we consider pair wise cuts as done by you, output will be :
  (John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 --- (john) 1 7 8 -- (Mary) 8 1
  7
  minimum cuts = 3

  On Tue, Jan 11, 2011 at 8:38 PM, Jammy xujiayiy...@gmail.com wrote:
   @Arpit Please explain your solution to me. As far as I understand,
   every alternate of two person should sum up equally.  Which means
   every pair of (john, mary) has the same sum for john and mary.

   On Jan 11, 2:55 am, Arpit Sood soodfi...@gmail.com wrote:
@jammy your code isnt working for the mentioned test case.
One simple approach is to go greedy on the test data, but that wont
   always
give the optimum answer.

On Tue, Jan 11, 2011 at 1:11 PM, Arpit Sood soodfi...@gmail.com wrote:
 the output for first test case is wrong it should be
 (John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 1 7 8 -- (Mary) 8 1 7
 minimum cuts made are 2

 On Tue, Jan 11, 2011 at 10:04 AM, Jammy xujiayiy...@gmail.com wrote:

 (a) it is intuitive to see we need to make a recursive function which
 takes  the following arguments:
    1) array,
    2) start index,
    3) length of the array,
    4) a sentinel indicating if it is the first half or second half
    5) a sum if it is the second half
    6) number of cuts so far
    7) a global minimal cuts

 So my recursive function looks something like this,
 void cutMinHelper(int *arr, int start, int len, bool isFirst, int 
 sum,
 int cut, int minV, vectorint res);

 and its wrapper just takes two arguments
 void cutMin(int *arr, int len);

 The idea is to differentiate the first half and second half. If it's
 the first half, you need make all possible cuts, and recursive call
 itself to get the second done. If it's the second half, you need
 calculate sums all the way to the end. Break out of the loop if it
 equals to the sum of the first part. And then recursively call itself
 to get the first half done.

 I hope my code explains the idea...Please report any bugs you find :)

 vectorint minVector; //storing the cuts

 void cutMin(int *arr, int len){
        int cut=0, minV = INT_MAX;
        vectorint res;
        cutMinHelper(arr, 0, len, true, 0, cut, minV, res);
        if(minVINT_MAX){
                coutminimal cut isminVendl;
        }

 }

 void cutMinHelper(int *arr, int start, int len, bool isFirst, int 
 sum,
 int cut, int minV, vectorint res){
        if(isFirst  startlen){
                if(start==0) cut = 0;
                int sum = arr[start];
                cut++;
                for(int i = start+1; i  len; i++){
                        vectorint addOne = res;
                        addOne.push_back(i-1);
                        cutMinHelper(arr, i , len, !isFirst, sum, cut,
 minV, addOne);
                        sum += arr[i];
                }
        }
        if(!isFirst  startlen){
            int i, sum2 = 0;
                for(i = start; i  len; i++){
                        sum2 += arr[i];
                        if(sum2 == sum){
                                break;
                        }
                }
                if( i==len-1  sum2==sum) {
                        if(cutminV){
                                minV = cut;
                                minVector = res;
                        }
                }
                if(ilen-1){
                        cut++;
                        vectorint addOne = res;
                        addOne.push_back(i);
                        cutMinHelper(arr, i+1, len, !isFirst, 0, cut,
   minV,
 addOne);
                }
        }
 }

 (b) I didn't write the code, but I think the code would look like the
 first one with few modifications.

 On Jan 10, 1:08 pm, shady sinv...@gmail.com wrote:
  Given an array of numbers : a1, a2, a3. an
  (a)    divide them in such a way that every alternate segment is
   given
 to
  two persons john and mary, equally the number of segments made
 should be
  minimum...
  eg

  1   2   3   >