[algogeeks] Directi Written Q 2012

2012-07-24 Thread ruru
find no. of 1's in binary format of numbers from 1 to 100. like for 1 to 10 answer is 17 -- 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

Re: [algogeeks] Max sum circular array

2012-07-24 Thread hary rathor
we can be use logical window and slide through the array in circular manner. apply kandane's algo on logical window. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Directi Written Q 2012

2012-07-24 Thread Avinash Mishra
#includeiostreamusing namespace std;int main(){int count=0;int count1=0;for(int i=0;i11;i++){ count=0;for(int j=0;j4;j++)if((i (1j)) 0){count++;} count1+=count;}coutcount1;return 0;} it will be better if u use java limit of j will be more in case 100 or 200 so use If Integer.Bitcount() value if

Re: [algogeeks] Directi Written Q 2012

2012-07-24 Thread Tanuj Makkar
the answer is 319 On Tue, Jul 24, 2012 at 3:09 PM, ruru soupti...@gmail.com wrote: find no. of 1's in binary format of numbers from 1 to 100. like for 1 to 10 answer is 17 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: Directi Written Q 2012

2012-07-24 Thread lomash goyal
//the following functions will count number of bits in the number int countbits(int n) { int count=0; while(n) { n/=2; count++; } return count; } int countnumberof1(int number) { if(number==0) return 0; if(number==1) return 1; if(number==2) return 2; if(number==3) return

[algogeeks] Re: Directi Written Q 2012

2012-07-24 Thread Dave
@Ruru: int i,j,sum=100*101/2; for( i = 1 ; i = 100 ; ++i ) { j = i; while( j ) { j = 1; sum -= j } } printf(%i\n,sum); Dave On Tuesday, July 24, 2012 4:39:42 AM UTC-5, ruru wrote: find no. of 1's in binary format of numbers from 1 to 100. like for 1 to 10

Re: [algogeeks] Directi Written Q 2012

2012-07-24 Thread Lomash Goyal
// count number of 1's upto n.cpp : Defines the entry point for the console application. // #include stdafx.h #includemath.h #includeconio.h //the following functions will count number of bits in the number int countbits(int n) { int count=0; while(n) { n/=2; count++; } return

Re: [algogeeks] Re: Directi Written Q 2012

2012-07-24 Thread Lomash Goyal
@dave sir-your algorithm is having a complexity of n(2) but the solution that i have given is of log(n) i guess. On Tue, Jul 24, 2012 at 8:10 PM, Dave dave_and_da...@juno.com wrote: @Ruru: int i,j,sum=100*101/2; for( i = 1 ; i = 100 ; ++i ) { j = i; while( j ) { j =

Re: [algogeeks] Directi Written Q 2012

2012-07-24 Thread algo bard
#includestdio.h #define RANGE_START 0 #define RANGE_END 100 int main() { int i,n,ctr=0; for( i=RANGE_START ; i=RANGE_END ; i++) { n = i; while(n) // Using Brian Kernighan's Algorithm to count the number of set bits in a number. { n= nn-1;

Re: [algogeeks] [Amazon]

2012-07-24 Thread algo bard
@Shobhit: Can you give me a few hints on implementing a BS on the 2D? @neelpulse: That's what I said. A 2D array *might* be a probable candidate. In your example, the first 2d satisfies the criteria...so we check it -- Not found -- Reject -- Move on to next probable candidate. On Sat, Jul 21,

[algogeeks] Re: Amazon support engineer

2012-07-24 Thread Tushar
this is interview street post here freely all the best On Monday, 23 July 2012 19:40:12 UTC+5:30, rahul sharma wrote: Guys i am having amazon support engg. test tonyt...90 min 27 questions mcq...plz tell how to prepare and wats dis profyl???reply asap..and sory for posting it in algogeeks

Re: [algogeeks] [Amazon]

2012-07-24 Thread SHOBHIT GUPTA
Sorry , I've tried but BS will not work here . On Tue, Jul 24, 2012 at 9:17 PM, algo bard algo.b...@gmail.com wrote: @Shobhit: Can you give me a few hints on implementing a BS on the 2D? @neelpulse: That's what I said. A 2D array *might* be a probable candidate. In your example, the first 2d

Re: [algogeeks] Directi Written Q 2012

2012-07-24 Thread manish untwal
I think the question is in the written round!!! On Tue, Jul 24, 2012 at 9:11 PM, algo bard algo.b...@gmail.com wrote: #includestdio.h #define RANGE_START 0 #define RANGE_END 100 int main() { int i,n,ctr=0; for( i=RANGE_START ; i=RANGE_END ; i++) { n = i;

[algogeeks] Queue problem

2012-07-24 Thread Hariraman R
Which of the following queue creates overflow when the no of elements is less than the queue size?? 1)single queue 2)priority queue 3)dequeue 4)circular queue Kindly explain what is the answer and why??? Thanks in advance.. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Directi Written Q 2012

2012-07-24 Thread manish untwal
and we don't need the code!! On Tue, Jul 24, 2012 at 10:30 PM, manish untwal manishuntw...@gmail.comwrote: I think the question is in the written round!!! On Tue, Jul 24, 2012 at 9:11 PM, algo bard algo.b...@gmail.com wrote: #includestdio.h #define RANGE_START 0 #define RANGE_END 100

Re: [algogeeks] Queue problem

2012-07-24 Thread Mind Boggler
Circular queue Expalanation- think of the condition for overflow On 24-Jul-2012, at 9:52 PM, Hariraman R rpharira...@gmail.com wrote: Which of the following queue creates overflow when the no of elements is less than the queue size?? 1)single queue 2)priority queue 3)dequeue 4)circular

[algogeeks] Re: Queue problem

2012-07-24 Thread Varun
Circular Queue, as it will overwrite in that case. I am not sure, if I understood the question correctly though. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Queue problem

2012-07-24 Thread Hariraman R
@mind blogger, Thank u:) Got it...:) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

[algogeeks]

2012-07-24 Thread Mind Boggler
Traditional decryption problem Convert a3b2c5 into aaabbc Can anyone Put forward an algo for the test case: a3b1c3d1 Thanx -- 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: Question asked in Amazon online test

2012-07-24 Thread Amit
Let's define a term RANDOMNESS of array as... summation of position of each 1's for eg RANDOMNESS for (0,0,1,0,1,0,1,1) will be 23 now calculate max possible RANDOMNESS for the given array (each 1 on max possible right position) here it will be 26 so ans will be-- MAX RANDOMNESS of given array

Re: [algogeeks]

2012-07-24 Thread Sathish babu
can anyone provide the code to convert ab1cd3 to abcddd **~Sathish Babu~** On Tue, Jul 24, 2012 at 11:39 PM, Mind Boggler min.b...@gmail.com wrote: Traditional decryption problem Convert a3b2c5 into aaabbc Can anyone Put forward an algo for the test case: a3b1c3d1 Thanx -- You

[algogeeks] sequence

2012-07-24 Thread mike miller
3,8,12,17,22,28,35 what is the nth term of this sequence... plz help it is the spoj problem on the last page of the problem set, problem code is as ARD1 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Queue problem

2012-07-24 Thread Madhukar Bharti
I Think Single queue as if rear =Size-1 and we are performing dequeue operation and now want to add an element then it will say that queue is overflow but still queue have spaces and to avoid this circular queue concept came.. please correct me if i m wrong...!! -- You received this

Re: [algogeeks] Re: Queue problem

2012-07-24 Thread Priyanka Raju
The answer is single queue... If we fill the queue fully and then dequeue and try again to enqueue... We will get the error.. This is because when we dequeue,we move the front pointer of the queue but not the rear pointer.. But enqueue is at rear end.. The condition for enqueue also checks the