@ross...

I have adoubt regarding this question...

what should be output if the matrix is like this..

1 1 2
1 3 1
2 3 4

U reply I will tell you then what doubt I have.

On Mon, May 30, 2011 at 10:36 AM, Vishal Thanki <[email protected]>wrote:

> Okay, i thought it this way: iterate through the whole matrix, and
> take the value  as a "key" to a hash table. and the value
> corresponding to the key would be the "count". increment the count
> everytime you encounter the same key. it is very easy to implement
> this in python (using dictionary) but i am not sure what will be the
> most efficient data structure to implement this in c/c++.
>
> Vishal
>
> On Mon, May 30, 2011 at 10:31 AM, ross <[email protected]> wrote:
> > @vishal
> > Hi,
> > I do not get you.
> > Can you please elaborate a little more how you ll use hash?
> >
> > On May 30, 8:50 am, Vishal Thanki <[email protected]> wrote:
> >> what about using a hash function?
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Mon, May 30, 2011 at 10:18 AM, ross <[email protected]> wrote:
> >> > Given a matrix, you need to find the number of blocks in it.
> >> > A block has the same numbers.
> >> > EG:
> >> > 1 1 3
> >> > 1 2 3
> >> > 2 2 4
> >> > has 4 blocks namely,
> >> > 1 1
> >> > 1
> >> >   2
> >> > 2 2
> >>
> >> > 3
> >> > 3
> >>
> >> > 4
> >>
> >> > 1 2 3
> >> > 4 5 6
> >> > 7 8 9
> >> > has 9 blocks
> >>
> >> > 1 1 1
> >> > 1 1 3
> >> > 4 4 5
> >> > has 4 blocks,
> >> > 1 1 1
> >> > 1 1
> >>
> >> > 3
> >>
> >> > 5
> >>
> >> > 4 4
> >>
> >> > I used an algorithm as follows,
> >> > for each element[i,j] in the matrix,
> >> >   enqueue adjacent indices into a queue if they contain the same
> >> > element.
> >> >  else
> >> > incremt blockcount;
> >>
> >> > return blockcount;
> >>
> >> > But, this complexity is O(n^3) any better solution exists?
> >>
> >> > --
> >> > You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> >> > To post to this group, send email to [email protected].
> >> > To unsubscribe from this group, send email to
> [email protected].
> >> > For more options, visit this group athttp://
> 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 [email protected].
> > To unsubscribe from this group, send email to
> [email protected].
> > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=100000655377926 *

@ross

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to