Question 1 Which data structure is appropriate to store customers waiting in lin
ID: 3833136 • Letter: Q
Question
Question 1
Which data structure is appropriate to store customers waiting in line at a clinic for a flu shots?
Queue
Stack
Linked List
Array
Question 2
Suppose a template function is defined as follows:
template<typename T>
void printArray(T list[], int arraySize)
{
for (int i = 0; i < arraySize; i++)
{
cout << list[i] << " ";
}
cout << endl;
}
Which of the following statements are correct?
int list[] = {1, 2, 3, 4}; printArray(list, 4);
double list[] = {1, 2, 3, 4}; printArray(list, 4);
int list[] = {1, 2.5, 3, 4}; printArray(list, 4);
string list[] = {"Atlanta", "Dallas", "Houston", "Chicago"}; printArray(list, 4);
Question 3
Suppose the rule of the party is that the participants who arrive later will leave earlier. Which data structure is appropriate to store the participants?
Queue
Stack
Linked List
Array
Question 4
If you have to randomly add or delete the elements anywhere in a container and you could not know its size in advance, what containers should you use?
array
linked list
vector
stack
Question 5
If the number of elements in the program is fixed, what data structure should you use?
array
stack
linked list
vector
Question 6
Which of the following statements are true?
Friends are used exactly the same for template and nontemplate classes.
A nontemplate class can be derived from a class template specialization.d. Stack<int,double> s;
A class template can be derived from a nontemplate class.
You can define static members in a template class. Each template specialization has its own copy of a static data field.
A class template can be derived from a class template.
Question 7
Which of the following two versions of the class declarations is correct?
Version I:
class A
{
public:
A()
{
}
private:
A* a;
int i;
};
Version II:
class A
{
public:
A()
{
}
private:
A a;
int i;
};
Both versions are wrong.
Version I is correct.
Version II is correct.
Both versions are correct.
Queue
Stack
Linked List
Array
Explanation / Answer
1). Queue
2) All of them are correct
3) Stack
4) Vector
5) Array
6) A class template can be derived from a nontemplate class.
Rest I am not sure
7) Version I is correct
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.