Skip to main content
1-Visitor
April 30, 2015
Solved

Programming question

  • April 30, 2015
  • 1 reply
  • 1203 views


I have a matrix with two columns. The first column is sorted and there are repeating elements in the first column with the corresponding elements in the second column.

I want to keep the element from the first column that have lowest value in the second column, the rest should be deleted. So there should be no repeating elements in the first

column and the element that is kept has lowest number in the second column.( compared to its repeated elements ).

Anyone who has an alghoritm for that or ideas ?

Best answer by StuartBruff

aagic wrote:


I have a matrix with two columns. The first column is sorted and there are repeating elements in the first column with the corresponding elements in the second column.

I want to keep the element from the first column that have lowest value in the second column, the rest should be deleted. So there should be no repeating elements in the first

column and the element that is kept has lowest number in the second column.( compared to its repeated elements ).

Anyone who has an alghoritm for that or ideas ?

Do you mean something like the attached?

(caveat: I haven't checked it, I've just sneaked it together whilst waiting for my PC to do something else work-related ...)

Stuart

1 reply

23-Emerald V
April 30, 2015

aagic wrote:


I have a matrix with two columns. The first column is sorted and there are repeating elements in the first column with the corresponding elements in the second column.

I want to keep the element from the first column that have lowest value in the second column, the rest should be deleted. So there should be no repeating elements in the first

column and the element that is kept has lowest number in the second column.( compared to its repeated elements ).

Anyone who has an alghoritm for that or ideas ?

Do you mean something like the attached?

(caveat: I haven't checked it, I've just sneaked it together whilst waiting for my PC to do something else work-related ...)

Stuart

aagic1-VisitorAuthor
1-Visitor
April 30, 2015

Hi Stuart,

it seams to be correct. Excellent, thanks !!

Adnan