find the least value from the vector

May 21, 2016 at 6:00am
Hi

how can I find the least value from the vector

 
vector< list< pair<int, int> > > MST(vertices + 1);
May 21, 2016 at 10:34am
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?
May 21, 2016 at 11:27am
Least value of one of many lists
May 21, 2016 at 11:30am
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?
May 22, 2016 at 2:59pm
Can you please tell me how can I compare one vale of a pair with other to find the least
May 22, 2016 at 3:36pm
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/
May 23, 2016 at 10:18am
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
May 23, 2016 at 12:28pm
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 May 23, 2016 at 12:29pm
May 24, 2016 at 11:09am
let me try and see..thanks
Topic archived. No new replies allowed.