Deck 10: Sets and Maps

ملء الشاشة (f)
exit full mode
سؤال
Searching for a particular value in a sequential container is generally an O(__________) process.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
You retrieve an object from a map by specifying its __________.
سؤال
What mathematicians call a(n) __________ can be thought of as a collection of objects.
سؤال
What is the result of performing the following operation?
{1, 3, 5, 7} - {2, 3, 4, 5}

A) {-1, 0, 1, 2}
B) {1, 7}
C) {2, 4}
D) {1, 0, -1, -2}
سؤال
There are no set union, set intersection, or set difference member functions in the C++ set class.
سؤال
Suppose you are given two sets:
Set1 = {Apples, Peaches, Pineapples}
Set2 = {Apples, Grapes, Peaches}
The result of set1* set2 is __________.

A) {Peaches}
B) {Apples}
C) {Apples, Peaches}
D) {Apples, Grapes, Peaches, Pineapples}
سؤال
The vector and set both implement the common requirements of the container classes.
سؤال
The __________ is the same as the set except that it does not impose the requirement that the items be unique.
سؤال
If the set fruits is
{"Apples", "Grapes", "Oranges", "Peaches", "Pears", "Pineapples", "Tomatoes"},
Then
Lower_bound("Oranges")
Would return an iterator to "__________", and
Upper_bound("Pineapples")
Would return an iterator to "Tomatoes".

A) Apples
B) Grapes
C) Oranges
D) Peaches
سؤال
Mathematically a(n) __________ is a set of ordered pairs whose elements are known as the key and the value.
سؤال
Items are stored in a map as ordered by their __________ function.
سؤال
Because the map class overloads the subscript operator such that the key is used as an index, a map is also known as a(n) __________ array.

A) random
B) relational
C) sequential
D) associative
سؤال
Which of the following lines corrects the error in the Map class function?
<strong>Which of the following lines corrects the error in the Map class function?  </strong> A) Value_Type operator[ ](const Key_Type& key) B) Value_Type& operator( )(const Key_Type& key) C) std::pair<iterator, bool> ret = the_set.insert(Entry_Type(key, Value_Type())); D) std::pair<iterator, bool> ret = the_set.insert(Entry_Type(key, ())); <div style=padding-top: 35px>

A) Value_Type operator[ ](const Key_Type& key)
B) Value_Type& operator( )(const Key_Type& key)
C) std::pair<iterator, bool> ret =
the_set.insert(Entry_Type(key, Value_Type()));
D) std::pair<iterator, bool> ret =
the_set.insert(Entry_Type(key, ()));
سؤال
The default value for the Compare template parameter is the Key_Type's __________ operator.

A) less-than-or-equal-to
B) less-than
C) greater-than
D) greater-than-or-equal-to
سؤال
The subscript operator is defined for the multimap.
سؤال
The goal of the hash table is to access an entry based on its __________ value, not its location.
سؤال
Using a hash table enables us to retrieve an item in __________.

A) O(1)
B) expected O(1)
C) O(log n)
D) O(n)
سؤال
The statement
int index = uni_char % __________;
computes an array index between 0 and 499 for a Unicode character.
سؤال
To reduce the clustering of indexes in hash tables, __________ probing uses increments that form the series:
(1 + 22+ 32; + · · ·).

A) constant
B) linear
C) quadratic
D) exponential
سؤال
An alternative to open addressing is a technique called __________, in which each table element references a linked list that contains all the items that hash to the same table index.
سؤال
__________ hashing grows linked lists to store key values associated with a particular index.
سؤال
Consider the formula for evaluating the number of hash table comparisons:
c=1/2(1+1/(1L)) c=1 / 2^{(1+1 /(1-L))} , where c = the number of comparisons and L = the load factor.
Given that a hash table of size 100,000 contains 20,000 items, how many comparisons are expected in a linear probe for an item?

A) .5
B) .625
C) 1.125
D) 3
سؤال
Worst-case performance for a hash table or a binary search tree is O(__________).

A) 1
B) log n
C) n
D) n log n
سؤال
Static data members must be initialized inside the class declaration.
سؤال
A hash function that evaluates indexes based on an original int value modulo the size of the hash table tends to uniformly distribute keys.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 10: Sets and Maps
1
Searching for a particular value in a sequential container is generally an O(__________) process.
n
2
You retrieve an object from a map by specifying its __________.
key
3
What mathematicians call a(n) __________ can be thought of as a collection of objects.
set
4
What is the result of performing the following operation?
{1, 3, 5, 7} - {2, 3, 4, 5}

A) {-1, 0, 1, 2}
B) {1, 7}
C) {2, 4}
D) {1, 0, -1, -2}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
5
There are no set union, set intersection, or set difference member functions in the C++ set class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
6
Suppose you are given two sets:
Set1 = {Apples, Peaches, Pineapples}
Set2 = {Apples, Grapes, Peaches}
The result of set1* set2 is __________.

A) {Peaches}
B) {Apples}
C) {Apples, Peaches}
D) {Apples, Grapes, Peaches, Pineapples}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
7
The vector and set both implement the common requirements of the container classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
8
The __________ is the same as the set except that it does not impose the requirement that the items be unique.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
9
If the set fruits is
{"Apples", "Grapes", "Oranges", "Peaches", "Pears", "Pineapples", "Tomatoes"},
Then
Lower_bound("Oranges")
Would return an iterator to "__________", and
Upper_bound("Pineapples")
Would return an iterator to "Tomatoes".

A) Apples
B) Grapes
C) Oranges
D) Peaches
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
10
Mathematically a(n) __________ is a set of ordered pairs whose elements are known as the key and the value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
11
Items are stored in a map as ordered by their __________ function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
12
Because the map class overloads the subscript operator such that the key is used as an index, a map is also known as a(n) __________ array.

A) random
B) relational
C) sequential
D) associative
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following lines corrects the error in the Map class function?
<strong>Which of the following lines corrects the error in the Map class function?  </strong> A) Value_Type operator[ ](const Key_Type& key) B) Value_Type& operator( )(const Key_Type& key) C) std::pair<iterator, bool> ret = the_set.insert(Entry_Type(key, Value_Type())); D) std::pair<iterator, bool> ret = the_set.insert(Entry_Type(key, ()));

A) Value_Type operator[ ](const Key_Type& key)
B) Value_Type& operator( )(const Key_Type& key)
C) std::pair<iterator, bool> ret =
the_set.insert(Entry_Type(key, Value_Type()));
D) std::pair<iterator, bool> ret =
the_set.insert(Entry_Type(key, ()));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
14
The default value for the Compare template parameter is the Key_Type's __________ operator.

A) less-than-or-equal-to
B) less-than
C) greater-than
D) greater-than-or-equal-to
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
15
The subscript operator is defined for the multimap.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
16
The goal of the hash table is to access an entry based on its __________ value, not its location.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
17
Using a hash table enables us to retrieve an item in __________.

A) O(1)
B) expected O(1)
C) O(log n)
D) O(n)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
18
The statement
int index = uni_char % __________;
computes an array index between 0 and 499 for a Unicode character.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
19
To reduce the clustering of indexes in hash tables, __________ probing uses increments that form the series:
(1 + 22+ 32; + · · ·).

A) constant
B) linear
C) quadratic
D) exponential
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
20
An alternative to open addressing is a technique called __________, in which each table element references a linked list that contains all the items that hash to the same table index.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
21
__________ hashing grows linked lists to store key values associated with a particular index.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
22
Consider the formula for evaluating the number of hash table comparisons:
c=1/2(1+1/(1L)) c=1 / 2^{(1+1 /(1-L))} , where c = the number of comparisons and L = the load factor.
Given that a hash table of size 100,000 contains 20,000 items, how many comparisons are expected in a linear probe for an item?

A) .5
B) .625
C) 1.125
D) 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
23
Worst-case performance for a hash table or a binary search tree is O(__________).

A) 1
B) log n
C) n
D) n log n
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
24
Static data members must be initialized inside the class declaration.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
25
A hash function that evaluates indexes based on an original int value modulo the size of the hash table tends to uniformly distribute keys.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.