find the least value from the vector

Hi

how can I find the least value from the vector

 
vector< list< pair<int, int> > > MST(vertices + 1);
Least value of what? Least value of one of the many lists, or least value of one of the many pairs inside each of those lists, or least value of the two ints inside each of those many pairs, or least value of a single int inside one of those many pairs?
Least value of one of many lists
Where the value of a list is what? Is it the size of the list, or is it the sum of all the ints in every pair in that list, or something else?
Can you please tell me how can I compare one vale of a pair with other to find the least
You access the values in a pair with first and second

1
2
3
4
pair<int, int> somepair;

somepair.first = 3;
somepair.second = 4;


http://www.cplusplus.com/reference/utility/pair/pair/
thanks..but one more thing...how can I compare somepair of a list with sompair1 of the list?

My vector contains the lists of pairs, so I want to compare one pair's value with another pair's value...say first of one pair with first of another pair...

Thanks
You can compare one value with another with the > operator. Or the < operator. Or the == operator. Or the != operator.

Get the values from the pairs, do the comparison. This has all now been spelled out for you to a really, really basic level. Start thinking for yourself.
Last edited on
let me try and see..thanks
Topic archived. No new replies allowed.