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



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 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] 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 it is  int k
then for(int j=0;jk;j++)
hope u got it


On 24 July 2012 15:09, 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 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.




-- 
aviNash

-- 
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] 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 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: 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 4;
 if(number3)
{
int bits=countbits(number);
return 
[(2^bits-1)+countnumberof1(2^bits-1)+countnumberof1(number-2^bits-1)];
}
}

On Tuesday, July 24, 2012 3:09:42 PM UTC+5:30, ruru 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 view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/IFbki8Z8tUgJ.
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: 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 answer is 17 


-- 
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/-/c-FrS-OzdhsJ.
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] 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 count;
}


int countnumberof1(int number)
{
if(number==0)
return 0;
if(number==1)
return 1;
if(number==2)
return 2;
if(number==3)
return 4;
 if(number3)
{
int bits=countbits(number);
if(number==pow(2.0,bits)-1)
{
return pow(2.0,bits-1)+2*countnumberof1(pow(2.0,bits-1)-1);
}
else return
pow(2.0,bits-2)+2*countnumberof1(pow(2.0,bits-2)-1)+countnumberof1(number-(pow(2.0,bits-1)))+number-(pow(2.0,bits-1))+1;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
printf(%d,countnumberof1(10));
getch();
return 0;
}


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 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

Lomash Goyal
*
*

-- 
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: 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  = 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 answer is 17

  --
 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/-/c-FrS-OzdhsJ.

 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

Lomash Goyal
*
*

-- 
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] 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;
ctr++;
}

}

printf(%d ,ctr);
}

TC = No. of set bits in the given range of numbers.


On Tue, Jul 24, 2012 at 7:56 PM, Lomash Goyal lomesh.go...@gmail.comwrote:

 // 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 count;
 }


 int countnumberof1(int number)
 {
 if(number==0)
  return 0;
 if(number==1)
 return 1;
  if(number==2)
 return 2;
 if(number==3)
  return 4;
  if(number3)
  {
 int bits=countbits(number);
 if(number==pow(2.0,bits)-1)
  {
 return pow(2.0,bits-1)+2*countnumberof1(pow(2.0,bits-1)-1);
 }
  else return
 pow(2.0,bits-2)+2*countnumberof1(pow(2.0,bits-2)-1)+countnumberof1(number-(pow(2.0,bits-1)))+number-(pow(2.0,bits-1))+1;
 }
 }
 int _tmain(int argc, _TCHAR* argv[])
 {
 printf(%d,countnumberof1(10));
 getch();
  return 0;
 }


 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 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

 Lomash Goyal

 *
 *


  --
 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] [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, 2012 at 5:14 PM, neelpulse(Jadavpur University) 
neelpu...@gmail.com wrote:

 May be I am missing a few details. But Consider this 3D array:
 {
{
   {1,2},
   {7,8} // First 2D array
 },
 {
{3,4},
{9,10}
  }
 }
 If you search for 3 then your search in first step will give first 2D
 which actually does not contain 3. As per my interpretation of the problem,
 my array is holding the preconditions.

 On Friday, 20 July 2012 16:25:49 UTC+5:30, algo bard wrote:

 Compare the element with the first([0][0]) and the last
 element([n-1][n-1]) of each 2D array to pin down the 2D array it *might* be
 present in.
 After that you can follow this approach :  http://www.geeksforgeeks.org/*
 *archives/11337 http://www.geeksforgeeks.org/archives/11337

 If it's not present in that 2D, move on and search for the next target 2D.

 The Probable 2D target set will be given by :
 arr[i][0][0]=element=arr[i][**n-1][n-1].
 Reject the 2Ds which don't follow this condition.

 TC: O(n^2)

 Though, I think an O(n) approach must exist for this problem.

 On Fri, Jul 20, 2012 at 11:24 AM, Sakshi Agrawal sweetsaksh...@gmail.com
  wrote:

 How will you search an element in sorted 3D Array ?  ( Sorted in all the
 3 directions )

 --
 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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en 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/-/UKYO8gE0s08J.

 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: 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 as i need quick response.waiting for +ve 
 response soon...
 thnx


-- 
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/-/qytHyFXxaSsJ.
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] [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 satisfies the criteria...so we
 check it -- Not found -- Reject -- Move on to next probable candidate.

 On Sat, Jul 21, 2012 at 5:14 PM, neelpulse(Jadavpur University) 
 neelpu...@gmail.com wrote:

 May be I am missing a few details. But Consider this 3D array:
 {
{
   {1,2},
   {7,8} // First 2D array
 },
 {
{3,4},
{9,10}
  }
 }
 If you search for 3 then your search in first step will give first 2D
 which actually does not contain 3. As per my interpretation of the problem,
 my array is holding the preconditions.

 On Friday, 20 July 2012 16:25:49 UTC+5:30, algo bard wrote:

 Compare the element with the first([0][0]) and the last
 element([n-1][n-1]) of each 2D array to pin down the 2D array it *might* be
 present in.
 After that you can follow this approach :  http://www.geeksforgeeks.org/
 **archives/11337 http://www.geeksforgeeks.org/archives/11337

 If it's not present in that 2D, move on and search for the next target
 2D.

 The Probable 2D target set will be given by :
 arr[i][0][0]=element=arr[i][**n-1][n-1].
 Reject the 2Ds which don't follow this condition.

 TC: O(n^2)

 Though, I think an O(n) approach must exist for this problem.

 On Fri, Jul 20, 2012 at 11:24 AM, Sakshi Agrawal 
 sweetsaksh...@gmail.com wrote:

 How will you search an element in sorted 3D Array ?  ( Sorted in all
 the 3 directions )

 --
 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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en 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/-/UKYO8gE0s08J.

 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] 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;
 while(n)  // Using Brian Kernighan's Algorithm to count the number
 of set bits in a number.
 {
 n= nn-1;
 ctr++;
 }

 }

 printf(%d ,ctr);
 }

 TC = No. of set bits in the given range of numbers.


 On Tue, Jul 24, 2012 at 7:56 PM, Lomash Goyal lomesh.go...@gmail.comwrote:

 // 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 count;
 }


 int countnumberof1(int number)
 {
 if(number==0)
  return 0;
 if(number==1)
 return 1;
  if(number==2)
 return 2;
 if(number==3)
  return 4;
  if(number3)
  {
 int bits=countbits(number);
 if(number==pow(2.0,bits)-1)
  {
 return pow(2.0,bits-1)+2*countnumberof1(pow(2.0,bits-1)-1);
 }
  else return
 pow(2.0,bits-2)+2*countnumberof1(pow(2.0,bits-2)-1)+countnumberof1(number-(pow(2.0,bits-1)))+number-(pow(2.0,bits-1))+1;
 }
 }
 int _tmain(int argc, _TCHAR* argv[])
 {
 printf(%d,countnumberof1(10));
 getch();
  return 0;
 }


 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 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

 Lomash Goyal

 *
 *


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




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

-- 
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] 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 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] 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

 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;
 ctr++;
 }

 }

 printf(%d ,ctr);
 }

 TC = No. of set bits in the given range of numbers.


 On Tue, Jul 24, 2012 at 7:56 PM, Lomash Goyal lomesh.go...@gmail.comwrote:

 // 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 count;
 }


 int countnumberof1(int number)
 {
 if(number==0)
  return 0;
 if(number==1)
 return 1;
  if(number==2)
 return 2;
 if(number==3)
  return 4;
  if(number3)
  {
 int bits=countbits(number);
 if(number==pow(2.0,bits)-1)
  {
 return pow(2.0,bits-1)+2*countnumberof1(pow(2.0,bits-1)-1);
 }
  else return
 pow(2.0,bits-2)+2*countnumberof1(pow(2.0,bits-2)-1)+countnumberof1(number-(pow(2.0,bits-1)))+number-(pow(2.0,bits-1))+1;
 }
 }
 int _tmain(int argc, _TCHAR* argv[])
 {
 printf(%d,countnumberof1(10));
 getch();
  return 0;
 }


 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 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

 Lomash Goyal

 *
 *


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




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




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

-- 
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] 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 queue
 
 Kindly explain what is the answer and why??? 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.



[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 
https://groups.google.com/d/msg/algogeeks/-/Z-CCtRFK9CQJ.
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] 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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[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 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: 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 - RANDOMNESS of given array

On Saturday, June 23, 2012 11:34:55 AM UTC+5:30, zerocool142 wrote:

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

 Example:   Given the array (0,0,1,0,1,0,1,1) the minimum number of swaps 
 is 3. 


-- 
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/-/rugRBg0Q0-kJ.
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]

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 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] 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@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: 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 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/-/tGKuzl0ldwIJ.
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: 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 rear pointer alone


Thank you

Priyanka

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