Software Development Exam  >  Software Development Tests  >  Test: Hashmaps - 1 - Software Development MCQ

Test: Hashmaps - 1 - Software Development MCQ


Test Description

15 Questions MCQ Test - Test: Hashmaps - 1

Test: Hashmaps - 1 for Software Development 2024 is part of Software Development preparation. The Test: Hashmaps - 1 questions and answers have been prepared according to the Software Development exam syllabus.The Test: Hashmaps - 1 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Hashmaps - 1 below.
Solutions of Test: Hashmaps - 1 questions in English are available as part of our course for Software Development & Test: Hashmaps - 1 solutions in Hindi for Software Development course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: Hashmaps - 1 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study for Software Development Exam | Download free PDF with solutions
Test: Hashmaps - 1 - Question 1

Which of the following best describes a hashmap?

Detailed Solution for Test: Hashmaps - 1 - Question 1

Hashmaps allow constant-time access to elements based on their keys by using a hash function to convert the key into an array index.

Test: Hashmaps - 1 - Question 2

What is hashing in the context of hashmaps?

Detailed Solution for Test: Hashmaps - 1 - Question 2

Hashing is a method for converting a key into an array index using a hash function. The hash function maps the key to an array index.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Hashmaps - 1 - Question 3

Which of the following collision resolution techniques is used in separate chaining?

Detailed Solution for Test: Hashmaps - 1 - Question 3

Separate chaining uses linked lists to handle collisions. Each slot of the hashmap contains a linked list of key-value pairs.

Test: Hashmaps - 1 - Question 4

What is the purpose of open addressing in hashmaps?

Detailed Solution for Test: Hashmaps - 1 - Question 4

Open addressing is used to find the next available slot in the hashmap when a collision occurs. It avoids storing multiple values for the same key.

Test: Hashmaps - 1 - Question 5

The Rabin-Karp algorithm is primarily used for which of the following?

Detailed Solution for Test: Hashmaps - 1 - Question 5

The Rabin-Karp algorithm is primarily used for string matching. It efficiently finds occurrences of a pattern string within a longer text string.

Test: Hashmaps - 1 - Question 6

What will be the output of the following code?
#include <iostream>
#include <unordered_map>

int main() {
    std::unordered_map<int, std::string> map;
    map[1] = "Alice";
    map[2] = "Bob";
    map[3] = "Charlie";

    std::cout << map[2] << std::endl;
    return 0;
}

Detailed Solution for Test: Hashmaps - 1 - Question 6

The code assigns values to keys in the hashmap and then retrieves the value associated with the key 2, which is "Bob". The output will be "Bob".

Test: Hashmaps - 1 - Question 7

What will be the output of the following code?
#include <iostream>
#include <unordered_map>

int main() {
    std::unordered_map<int, int> map;

    for (int i = 0; i < 5; i++) {
        map[i] = i * 10;
    }

    std::cout << map[5] << std::endl;
    return 0;
}

Detailed Solution for Test: Hashmaps - 1 - Question 7

The code assigns values to keys from 0 to 4, but the key 5 is not assigned a value. Accessing map[5] will return a default-constructed value, which is 0 for integers.

Test: Hashmaps - 1 - Question 8

What will be the output of the following code?
#include <iostream>
#include <unordered_map>

int main() {
    std::unordered_map<int, int> map;

    map[1] = 10;
    map[2] = 20;
    map[3] = 30;
    map[4] = 40;

    std::cout << map.size() << std::endl;
    return 0;
}

Detailed Solution for Test: Hashmaps - 1 - Question 8

The code assigns values to four different keys in the hashmap. The 'size()' function returns the number of elements in the hashmap, which is 4 in this case.

Test: Hashmaps - 1 - Question 9

What will be the output of the following code?
#include <iostream>
#include <unordered_map>

int main() {
    std::unordered_map<int, int> map;

    map[1] = 10;
    map[2] = 20;
    map[3] = 30;
    map[4] = 40;

    map.erase(2);

    std::cout << map.size() << std::endl;
    return 0;
}

Detailed Solution for Test: Hashmaps - 1 - Question 9

The code assigns values to four different keys in the hashmap and then erases the key 2. The 'size()' function returns the number of elements in the hashmap, which is 3 after erasing.

Test: Hashmaps - 1 - Question 10

What will be the output of the following code?
#include <iostream>
#include <unordered_map>

int main() {
    std::unordered_map<char, int> map;

    map['a'] = 1;
    map['b'] = 2;
    map['c'] = 3;
    map['d'] = 4;

    std::cout << map['z'] << std::endl;
    return 0;
}

Detailed Solution for Test: Hashmaps - 1 - Question 10

The code assigns values to keys 'a' to 'd', but the key 'z' is not assigned a value. Accessing map['z'] will return a default-constructed value, which is 0 for integers.

Test: Hashmaps - 1 - Question 11

Which of the following hashing techniques uses the concept of linear probing?

Detailed Solution for Test: Hashmaps - 1 - Question 11

Linear probing is a technique used in open addressing, not separate chaining. Separate chaining uses linked lists to handle collisions.

Test: Hashmaps - 1 - Question 12

Which of the following statements about open addressing is false?

Detailed Solution for Test: Hashmaps - 1 - Question 12

Open addressing can handle a limited number of elements due to the need to find the next available slot. Separate chaining can handle more elements by using linked lists.

Test: Hashmaps - 1 - Question 13

The Rabin-Karp algorithm uses which of the following concepts?

Detailed Solution for Test: Hashmaps - 1 - Question 13

The Rabin-Karp algorithm uses a rolling hash function to efficiently compare the pattern string with substrings of the text string.

Test: Hashmaps - 1 - Question 14

Which of the following collision resolution techniques is used in open addressing?

Detailed Solution for Test: Hashmaps - 1 - Question 14

Linear probing is a collision resolution technique used in open addressing. It probes the next slot in a linear fashion until an available slot is found.

Test: Hashmaps - 1 - Question 15

Which of the following is a drawback of using separate chaining for collision resolution?

Detailed Solution for Test: Hashmaps - 1 - Question 15

Separate chaining requires additional memory to store linked lists for collisions, leading to increased memory usage compared to open addressing.

Information about Test: Hashmaps - 1 Page
In this test you can find the Exam questions for Test: Hashmaps - 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Hashmaps - 1, EduRev gives you an ample number of Online tests for practice

Top Courses for Software Development

Download as PDF

Top Courses for Software Development