What i want is to first store the given input as follows :- {{{A,B},{B,C},{C,D}},{{A,C},{C,E},{E,F},{F,P}}} and then make a check if the pair is present in particular subset of a set. For e.g if the user can give index 0 and pair {B,C} we need to search the first index value i.e {{A,B},{B,C},{C,D}} and return true or false based on its presence. What data structure i should use. I tried vector but not helping me Kindly help
My current implementation look like Code: struct ElementPair { string First_element; string Second_element; }; struct Element_set { vector<ElementPair> ElementPairs; }; void makeSet(string str1,string str2) { ... .... .. .... vector<Element_set > Pathset; Now i need to assign str1 to First_element and str2 to Second_element so that my final stored data look like {{{A,B},{B,C},{C,D}},{{D,E},{E,F}}}
Code: 0 1 2 3 0 (a,b),(b,c),(c,d) 1 (a,c),(c,e),(e,f),(f,g) 2 (a,b),(a,c),(b,d) Your data structure seems to be a ragged two-dimensional array of pairs. Depending on what you want to do with it, perhaps a vector of sets of pairs. If your base elements are just single characters you could use chars instead of strings.