Which of the following statements is true about hashmaps in C++?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
What is the time complexity of searching for an element in a hashmap?
In case of a collision in a hashmap, which technique is commonly used to handle it?
What will be the output of the following code?
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<int, std::string> colors;
colors[1] = "Red";
colors[2] = "Green";
colors[3] = "Blue";
std::cout << colors[2];
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<int, int> numbers;
numbers[1] = 10;
numbers[2] = 20;
numbers[3] = 30;
numbers[4] = 40;
std::cout << numbers[5];
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<std::string, int> ages;
ages["John"] = 25;
ages["Alice"] = 30;
ages["Bob"] = 35;
std::cout << ages["Alice"];
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<char, int> frequencies;
frequencies['a'] = 2;
frequencies['b'] = 3;
frequencies['c'] = 1;
std::cout << frequencies['d'];
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<int, std::string> colors;
colors[1] = "Red";
colors[2] = "Green";
colors[3] = "Blue";
std::unordered_map<int, std::string>::iterator it;
for (it = colors.begin(); it != colors.end(); it++) {
std::cout << it->second << " ";
}
return 0;
}
What is the time complexity of finding the maximum element in a hashmap?
Which of the following operations can be performed in O(1) time for a hashmap?
In a hashmap, how is the size of the underlying array typically chosen?
Which of the following is an advantage of using a hashmap over an array?
In C++, which header file is required to use the unordered_map class?
153 videos|115 docs|24 tests
|
153 videos|115 docs|24 tests
|