Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: An exploration of higher-level-language approaches to the "First all-zero row in an NxN matrix" problem (goto Considered Harmful)

by davido (Archbishop)
on Sep 24, 2011 at 20:18 UTC ( #927680=note: print w/ replies, xml ) Need Help??


in reply to Re: An exploration of higher-level-language approaches to the "First all-zero row in an NxN matrix" problem (goto Considered Harmful)
in thread An exploration of higher-level-language approaches to the "First all-zero row in an NxN matrix" problem (goto Considered Harmful)

I like that because it only does one comparison per row.

I considered a join approach too, but had two concerns. First, while it works in the specific case, if the NxN matrix held more complex strings, it could fail, so I saw it as not general enough to a broader application of the problem. Nevertheless, the problem itself is specific, and your version works great.

The other concern is that it lacks the optimization of failing as soon as the first non-zero entry is found on a given row. By joining the row, we're already implicitly touching the entire row. On the other hand, it does have the merit of only doing one comparison per row, which is nice. The shortcoming is that it has to join the entire row even if the first element of the row would result in a rejected row.

Fun!


Dave


Comment on Re^2: An exploration of higher-level-language approaches to the "First all-zero row in an NxN matrix" problem (goto Considered Harmful)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927680]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-08-28 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls