B
bele_harshad2006
how can i pick up largest no from 5 rows by 5 column matrix????
By copmaring the first with the send, then the larted of that comparisn withhow can i pick up largest no from 5 rows by 5 column matrix????
how can i pick up largest no from 5 rows by 5 column matrix????
Step 1. Sort the columns of each row into ascending order.
Step 2. Sort the rows into ascending order using the last column as
the key.
Step 3. Pick the last column of the last row.
(e-mail address removed) said:
I'm sure we can do better than O(c log c + r log r). Perhaps we should
specify a particular sort. That can get us right up to O(c^2 + r^2)
without any major effort. But can anyone find an exponential-time
algorithm?
Hmm, the OP talked abut 'no' wich I assume to mean 'number', so it probablyThere's a big problem here, though - how can we sort anything when we
don't know how to tell whether one thing is larger than another?
Hmm, the OP talked abut 'no' wich I assume to mean 'number', so it probably
is some integral or floating point number, which are fairly easy to find the
larger.
Hmm, the OP talked abut 'no' wich I assume to mean 'number', so it
probably
is some integral or floating point number, which are fairly easy to find
the
larger.
Me too I must admit. Isn't that what smileys have been invented for?CBFalconer said:You apparantly totally missed the humor involved in RH's post.
Richard Heathfield said:(e-mail address removed) said:
I'm sure we can do better than O(c log c + r log r). Perhaps we should
specify a particular sort. That can get us right up to O(c^2 + r^2)
without any major effort. But can anyone find an exponential-time
algorithm?
Me too I must admit. Isn't that what smileys have been invented for?
Richard said:(e-mail address removed) said:
I'm sure we can do better than O(c log c + r log r). Perhaps we should
specify a particular sort. That can get us right up to O(c^2 + r^2)
without any major effort. But can anyone find an exponential-time
algorithm?
Arrgh.. exponential-time??! The worst sorting algorithms I know, are
O(N^2). :-/
I can't remember Knuth or Sedgewick, discussing anything worse than
that.
Give a hint please..
Keith Thompson said:Google "permutation sort".
No matrices in C, sorry. We do have arrays though. Consider..how can i pick up largest no from 5 rows by 5 column matrix????
Richard Heathfield said:Tor Rustad said:
Well, let's see now...
while not sorted
exchange two elements at random
endwhile
That would do it, I think.
CBFalconer said:Yes it is, given sufficient time and a really random generator![]()
Yes it is, given sufficient time and a really random generator![]()
Me too I must admit. Isn't that what smileys have been invented for?
[email protected] said:how can i pick up largest no from 5 rows by 5 column matrix????
No matrices in C, sorry. We do have arrays though. Consider..
int arr[5][5];
Does this satisfy your description of a matrix?
The arr array has 25 elements. We can find the largest of them by simply
tripping through the array comparing 'this' one to the previously larger
one. The position of the largest element in the array might also be of
interest. Consider..
int i, j, r, c, max = 0;
for (i = 0; i < 5; ++i)
for (j = 0; j < 5; ++j)
if (arr[j] > max) {
max = arr[j];
r = i, c = j;
}
When this finishes, max will hold the largest int and r and c will tell
you where it is. And very quickly.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.