Professional Documents
Culture Documents
8.MapsQuiz (Quiz)
8.MapsQuiz (Quiz)
0. Title: Maps 01
Description: Which of the following is true about maps?
1. Title: Maps 02
Description: You need to store how many students scored some particular marks in
the JEE MAINS out of 320(assume only positive marks can be scored). Which of the
following is the most efficient?
0.A map where key is the score obtained and value is the number of students who got
this score.
1.a hashmap where key is the score obtained and value is the number of students who
got this score.
2.Store all student data in an array and simply loop throught to find students who
scored a particular score.
3.An array of 321 elements where marks[i] = x denotes x students got i marks.
2. Title: Maps 03
Description: Now imagine you need to store the number of people with a particular
net worth. which of the following is a good way to do that.
0.Still an array will be the most efficient way to the required info.
1.A map but only because it is not a good practice to use arrays.
2.A vector instead of an array should be used.
3.A map because it will require less memory.
3. Title: Maps 04
Description: Predict the output :
0.5 1
1.2 1
2.Runtime error because of an attempt to insert a duplicate key.
3.Runtime error because the key 3 does not exist in the map.
4. Title: Maps 05
Description: Which of the following will give a compile-time error?
0.map < pair < int, int >, pair<string, int > > myMap;
1.map < set< int >, pair< string, int > > myMap;
2.map < map < string, int >, long long > myMap;
3.None of them
5. Title: Maps 06
Description: What is the difference between Map and MultiMap associative
containers?
0.A map allows only unique keys wheras a multimap can have duplicate keys.
1.A map allows only unique values wheras a multimap can have duplicate values.
2.A multimap is made-up of maps.
3.It is possible to create many copies of multimap but not in the case of a map.
6. Title: Maps 07
Description: How will you efficiently print the largest key in a map?
7. Title: Maps 08
Description: What does the following code do?
vector< string > func(vector< string > paraGraph, int ct)
for(auto it = myMap.rbegin(); it !=
myMap.rend() && ct; it++)
someWords.push_back(it->first); ct--;
return someWords;
}
8. Title: Maps 09
Description: The following data type map < keyType, vector < valueType > > myMap :
You need to store this information and also return the color corresponding to the
point P(X,Y,Z) on demand, if P(X,Y,Z) is present in the N points.