Re: [algogeeks] Array with 0 and 1

2010-07-08 Thread Ratnesh Thakur
my algo is flawed..i took the matrix to be sorted

On 7/8/10, Ashish Goel  wrote:
> can you clarify ratnesh please
>
> i was thinknig on these lines...
>
> int temp=0; int rowcount=0;
> for (int row=0;row if (a[row]||temp!=temp)
> if (a[row]&~0!=0) rowcount++;
>
>
> for (int col=0;col if (a[col]||temp!=temp)
> if (a[col]&~0!=0) colcount++;
>
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
> On Wed, Jul 7, 2010 at 9:53 PM, Ratnesh Thakur
> wrote:
>
>> for(i=0 to n-1)
>>   if( binarysearch(i,n-1,1) + 1)
>>   count++
>> print count.
>> binarysearch(first,last,item)
>>  if(1 is there)
>>  return mid
>>  else
>>  return -1.
>> similarly we can go for coloumns.
>> o(nlogn)
>>
>> On 7/5/10, divya jain  wrote:
>> > i think u need to visit every element atleast once to see if its 1 or 0,
>> nd
>> > so update the count.
>> > so i dont think it will be possible in less than O(n2)
>> >
>> > On 5 July 2010 15:41, amit  wrote:
>> >
>> >>
>> >>
>> >> For a given matrix NxN having 0 or 1’s only. You have to find the
>> >> count of rows and columns where atleast one 1 occurs.
>> >>
>> >> e,g
>> >>
>> >> 0 0 0 0
>> >>
>> >> 1 0 0 1
>> >>
>> >> 1 0 0 1
>> >>
>> >> 1 1 0 1
>> >>
>> >> Row count having 1 atleast once: 3
>> >>
>> >> Col count having 1 atleast once: 3
>> >>
>> >> Any Solution less than O(n^2) will do
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Algorithm Geeks" group.
>> >> To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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 algoge...@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] Array with 0 and 1

2010-07-08 Thread Ashish Goel
can you clarify ratnesh please

i was thinknig on these lines...

int temp=0; int rowcount=0;
for (int row=0;rowwrote:

> for(i=0 to n-1)
>   if( binarysearch(i,n-1,1) + 1)
>   count++
> print count.
> binarysearch(first,last,item)
>  if(1 is there)
>  return mid
>  else
>  return -1.
> similarly we can go for coloumns.
> o(nlogn)
>
> On 7/5/10, divya jain  wrote:
> > i think u need to visit every element atleast once to see if its 1 or 0,
> nd
> > so update the count.
> > so i dont think it will be possible in less than O(n2)
> >
> > On 5 July 2010 15:41, amit  wrote:
> >
> >>
> >>
> >> For a given matrix NxN having 0 or 1’s only. You have to find the
> >> count of rows and columns where atleast one 1 occurs.
> >>
> >> e,g
> >>
> >> 0 0 0 0
> >>
> >> 1 0 0 1
> >>
> >> 1 0 0 1
> >>
> >> 1 1 0 1
> >>
> >> Row count having 1 atleast once: 3
> >>
> >> Col count having 1 atleast once: 3
> >>
> >> Any Solution less than O(n^2) will do
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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] Array with 0 and 1

2010-07-07 Thread Ratnesh Thakur
for(i=0 to n-1)
   if( binarysearch(i,n-1,1) + 1)
   count++
print count.
binarysearch(first,last,item)
  if(1 is there)
  return mid
  else
  return -1.
similarly we can go for coloumns.
o(nlogn)

On 7/5/10, divya jain  wrote:
> i think u need to visit every element atleast once to see if its 1 or 0, nd
> so update the count.
> so i dont think it will be possible in less than O(n2)
>
> On 5 July 2010 15:41, amit  wrote:
>
>>
>>
>> For a given matrix NxN having 0 or 1’s only. You have to find the
>> count of rows and columns where atleast one 1 occurs.
>>
>> e,g
>>
>> 0 0 0 0
>>
>> 1 0 0 1
>>
>> 1 0 0 1
>>
>> 1 1 0 1
>>
>> Row count having 1 atleast once: 3
>>
>> Col count having 1 atleast once: 3
>>
>> Any Solution less than O(n^2) will do
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@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 algoge...@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 algoge...@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] Array with 0 and 1

2010-07-05 Thread divya jain
i think u need to visit every element atleast once to see if its 1 or 0, nd
so update the count.
so i dont think it will be possible in less than O(n2)

On 5 July 2010 15:41, amit  wrote:

>
>
> For a given matrix NxN having 0 or 1’s only. You have to find the
> count of rows and columns where atleast one 1 occurs.
>
> e,g
>
> 0 0 0 0
>
> 1 0 0 1
>
> 1 0 0 1
>
> 1 1 0 1
>
> Row count having 1 atleast once: 3
>
> Col count having 1 atleast once: 3
>
> Any Solution less than O(n^2) will do
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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] Array with 0 and 1

2010-07-05 Thread amit


For a given matrix NxN having 0 or 1’s only. You have to find the
count of rows and columns where atleast one 1 occurs.

e,g

0 0 0 0

1 0 0 1

1 0 0 1

1 1 0 1

Row count having 1 atleast once: 3

Col count having 1 atleast once: 3

Any Solution less than O(n^2) will do

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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.