algorithm - Multi-variate maximization over a table -


I am doing a simple search to implement the algorithm that can find the row of the maximum value on a certain column Are there. Then, he should get all the rows that are close to the maximum value on a particular column (can these 2 steps be combined?) Then, out of the selected rows, I have to find someone who is the least in any other column The value is.

Bonus: If there are many such entries, then I will need to be of the lowest value on another column.

Yes, I know that it is easy to do this with SQL (ITE), but I do not want to waste time in parsing the data in the data test.

I am interested in a simple idea on how to do this (pseudocode is okay) and, right now, I can think of some complex as well as these lines:

  • Repeat on all rows & amp;
  • Find the minimum value in the new list of rows
  • Repeat all the rows again and "close" the list to the maximum. You are doing the right thing as long as your line values ​​are

    , you can not go through all the values ​​in step 1, so you will end up spending O (R) time there, where R is the number of rows.

    For the second stage, its cost is also O (R) , so it does not degrade the complexity of your algorithm.

    If we believe that the number of values ​​is "close to the maximum" is in relation to O (1) R , the third step is O (c) where c is the number of columns If your values ​​have not been resolved because you want to take the lowest value to test all the values is required.

    You will get the best complication in your algorithm.

Comments